Skip to content

Cobalt Web image Dockerfile #1366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jo-chemla
Copy link

Build and run image with

docker build -f web/Dockerfile -t cobalt-web .
docker run -e WEB_DEFAULT_API="https://real.api.endpoint" -e WEB_HOST="http://abc"  -e WEB_PLAUSIBLE_HOST="def" -p 800:80 cobalt-web

Currently, vite build still uses process.env env-vars at build time, so the docker container is not using those defined via placeholders in runtime-config.js

Build and run image with

```
docker build -f web/Dockerfile -t cobalt-web .
docker run -e WEB_DEFAULT_API="https://real.api.endpoint" -e WEB_HOST="http://abc"  -e WEB_PLAUSIBLE_HOST="def" -p 800:80 cobalt-web
```

Currently, vite build still uses process.env env-vars at build time, so the docker container is not using those defined via placeholders in `runtime-config.js`
@hyperdefined
Copy link
Contributor

Should use Caddy instead of NGINX.

This is my Dockerfile for hosting web: https://github.com/caninetools/cobalt/blob/main/docker-build/Dockerfile-web

Thanks for getting back @hyperdefined with the direction about using Caddy.
I cannot comment on the issue thread or PR anymore.
This is a fake commit to comment: do you want to edit the PR with your Dockerfile and make the vars editable via docker container env_vars?
@jo-chemla
Copy link
Author

Thanks for getting back @hyperdefined with the direction about using Caddy.
Do you want to edit the PR with your Dockerfile and make the vars editable via docker container env_vars?
Or should I give it a go on my side? Note it seems like it's currently working great with nginx.

@hyperdefined
Copy link
Contributor

hyperdefined commented Jul 2, 2025

I swapped to Caddy since I like it better personally, and I like how it's more lightweight.

As for the environment variables, they are in the build file itself. You can edit them yourself or manually copy in a .env file into the root of the web folder before the site is built.

The site is built in the container before it's published, so passing in environment variables during runtime won't do anything. It has to be done before it's built.

@jo-chemla
Copy link
Author

Thanks again for getting back! What's the point-of-view of the team regarding nginx vs Caddy for this cobalt-web docker image?

Also, this PR uses a docker-entrypoint.sh which replaces runtime docker env variables WEB_HOST, WEB_PLAUSIBLE_HOST, WEB_DEFAULT_API into placeholders in a runtime-config.js file. Only at the moment this config-file.js is not read by the built site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants