diff --git a/Dockerfile b/Dockerfile index f9e32313..07153148 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/doc/docker.md b/doc/docker.md index 910938f0..fc934999 100644 --- a/doc/docker.md +++ b/doc/docker.md @@ -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 +``` diff --git a/docker/dynamic-config.sh b/docker/dynamic-config.sh new file mode 100755 index 00000000..952cb969 --- /dev/null +++ b/docker/dynamic-config.sh @@ -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