Skip to content

Commit 1ef2c9c

Browse files
Generate Frontend config and serve it (#657)
See #656.
1 parent 42d83f1 commit 1ef2c9c

5 files changed

Lines changed: 21 additions & 2 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"oidcEnabled": $OIDC_ENABLED
3+
}

files/nginx/odk.conf.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ server {
6767
include /usr/share/odk/nginx/common-headers.conf;
6868
add_header Cache-Control no-cache;
6969
}
70+
location /client-config.json {
71+
include /usr/share/odk/nginx/common-headers.conf;
72+
add_header Cache-Control no-cache;
73+
}
7074
location /index.html {
7175
include /usr/share/odk/nginx/common-headers.conf;
7276
add_header Cache-Control no-cache;

files/prebuild/build-frontend.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash -eu
22
cd client
33
npm clean-install --no-audit --fund=false --update-notifier=false
4-
VUE_APP_OIDC_ENABLED="$OIDC_ENABLED" npm run build
4+
npm run build
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash -eu
2+
set -o pipefail
3+
4+
if [[ $OIDC_ENABLED != 'true' ]] && [[ $OIDC_ENABLED != 'false' ]]; then
5+
echo 'OIDC_ENABLED must be either true or false'
6+
exit 1
7+
fi
8+
9+
envsubst < files/nginx/client-config.json.template > /tmp/client-config.json

nginx.dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ FROM node:20.12.2-slim as intermediate
33
RUN apt-get update \
44
&& apt-get install -y --no-install-recommends \
55
git \
6+
gettext-base \
67
&& rm -rf /var/lib/apt/lists/*
78

89
COPY ./ ./
910
RUN files/prebuild/write-version.sh
11+
RUN files/prebuild/build-frontend.sh
1012
ARG OIDC_ENABLED
11-
RUN OIDC_ENABLED="$OIDC_ENABLED" files/prebuild/build-frontend.sh
13+
RUN files/prebuild/write-client-config.sh
1214

1315

1416

@@ -32,3 +34,4 @@ COPY files/nginx/*.conf* /usr/share/odk/nginx/
3234

3335
COPY --from=intermediate client/dist/ /usr/share/nginx/html
3436
COPY --from=intermediate /tmp/version.txt /usr/share/nginx/html
37+
COPY --from=intermediate /tmp/client-config.json /usr/share/nginx/html

0 commit comments

Comments
 (0)