Allow config override in docker image

This commit is contained in:
Hugh Nimmo-Smith 2023-01-11 18:06:25 +00:00
parent a565d2a7d3
commit df6474b637
3 changed files with 37 additions and 0 deletions

View File

@ -6,4 +6,9 @@ RUN yarn install \
&& yarn build
FROM docker.io/nginx:alpine
# Copy the dynamic config script
COPY ./docker/dynamic-config.sh /docker-entrypoint.d/99-dynamic-config.sh
# Copy the built app from the first build stage
COPY --from=builder /app/target /usr/share/nginx/html

View File

@ -56,3 +56,27 @@ docker run \
--publish 80:80 \
hydrogen
```
You can override the default `config.json` using the `CONFIG_OVERRIDE` environment variable. For example to specify a different Homeserver and :
```
docker run \
--name hydrogen \
--publish 80:80 \
--env CONFIG_OVERRIDE='{
"push": {
"appId": "io.element.hydrogen.web",
"gatewayUrl": "https://matrix.org",
"applicationServerKey": "BC-gpSdVHEXhvHSHS0AzzWrQoukv2BE7KzpoPO_FfPacqOo3l1pdqz7rSgmB04pZCWaHPz7XRe6fjLaC-WPDopM"
},
"defaultHomeServer": "https://fosdem.org",
"themeManifests": [
"assets/theme-element.json"
],
"defaultTheme": {
"light": "element-light",
"dark": "element-dark"
}
}' \
hydrogen
```

8
docker/dynamic-config.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
set -eux
# Use config override environment variable if set
if [ -n "${CONFIG_OVERRIDE:-}" ]; then
echo "$CONFIG_OVERRIDE" > /usr/share/nginx/html/config.json
fi