Skip to content

Commit

Permalink
Make the Docker image configurable at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
sandhose committed Apr 21, 2022
1 parent c01429d commit f4d0ba3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,21 @@ RUN yarn install
COPY . .
RUN yarn build

# Remove the default config, replace it with a symlink to somewhere that will be updated at runtime
RUN rm -f target/assets/config.json \
&& ln -sf /tmp/config.json target/assets/config.json

FROM --platform=${TARGETPLATFORM} docker.io/nginxinc/nginx-unprivileged:1.21-alpine

# Copy the config template as well as the templating script
COPY ./docker/config.json.tmpl /config.json.tmpl
COPY ./docker/config-template.sh /docker-entrypoint.d/99-config-template.sh

# Copy the built app from the first build stage
COPY --from=builder /app/target /usr/share/nginx/html

# Values from the default config that can be overridden at runtime
ENV PUSH_APP_ID="io.element.hydrogen.web" \
PUSH_GATEWAY_URL="https://matrix.org" \
PUSH_APPLICATION_SERVER_KEY="BC-gpSdVHEXhvHSHS0AzzWrQoukv2BE7KzpoPO_FfPacqOo3l1pdqz7rSgmB04pZCWaHPz7XRe6fjLaC-WPDopM" \
DEFAULT_HOMESERVER="matrix.org"
7 changes: 7 additions & 0 deletions docker/config-template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

set -eux

envsubst '$PUSH_APP_ID,$PUSH_GATEWAY_URL,$PUSH_APPLICATION_SERVER_KEY,$DEFAULT_HOMESERVER' \
< /config.json.tmpl \
> /tmp/config.json
8 changes: 8 additions & 0 deletions docker/config.json.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"push": {
"appId": "$PUSH_APP_ID",
"gatewayUrl": "$PUSH_GATEWAY_URL",
"applicationServerKey": "$PUSH_APPLICATION_SERVER_KEY"
},
"defaultHomeServer": "$DEFAULT_HOMESERVER"
}

0 comments on commit f4d0ba3

Please sign in to comment.