Skip to content

Commit 52b8b65

Browse files
committed
[DOP-29496] Allow reading settings from config.yml
1 parent ac884be commit 52b8b65

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

docker/Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@ COPY . .
1515
RUN yarn build
1616

1717

18+
FROM mikefarah/yq AS yq
1819
FROM nginx:stable-alpine AS prod
1920

2021
COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf
2122
COPY --from=build /app/dist /usr/share/nginx/html
2223

2324
COPY ./docker/entrypoint.sh /entrypoint.sh
24-
RUN chmod +x /entrypoint.sh
25+
COPY --from=yq /usr/bin/yq /usr/bin/yq
26+
RUN chmod +x /entrypoint.sh /usr/bin/yq
2527

26-
ARG API_URL=http://localhost:8000
27-
ARG AUTH_PROVIDER=dummyAuthProvider
28-
ENV SYNCMASTER__UI__API_BROWSER_URL=${API_URL}
29-
ENV SYNCMASTER__UI__AUTH_PROVIDER=${AUTH_PROVIDER}
28+
ENV SYNCMASTER_CONFIG_FILE=/app/config.yaml
3029

3130
ENTRYPOINT ["/entrypoint.sh"]
3231
CMD ["nginx", "-g", "daemon off;"]

docker/entrypoint.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
#!/bin/sh
22

3+
SYNCMASTER_CONFIG_FILE=${SYNCMASTER_CONFIG_FILE:-/app/config.yaml}
4+
SYNCMASTER__UI__API_BROWSER_URL_DEFAULT="http://localhost:8000"
5+
SYNCMASTER__UI__AUTH_PROVIDER_DEFAULT="dummyAuthProvider"
6+
7+
if [[ -z "${SYNCMASTER__UI__API_BROWSER_URL}" ]]; then
8+
if [[ -f "$SYNCMASTER_CONFIG_FILE" ]]; then
9+
SYNCMASTER__UI__API_BROWSER_URL=$(yq --raw-output ".ui.api_browser_url // \"$SYNCMASTER__UI__API_BROWSER_URL_DEFAULT\"" "$SYNCMASTER_CONFIG_FILE")
10+
else
11+
SYNCMASTER__UI__API_BROWSER_URL="$SYNCMASTER__UI__API_BROWSER_URL_DEFAULT"
12+
fi
13+
fi
14+
15+
if [[ -z "${SYNCMASTER__UI__AUTH_PROVIDER}" ]]; then
16+
if [[ -f "$SYNCMASTER_CONFIG_FILE" ]]; then
17+
SYNCMASTER__UI__AUTH_PROVIDER=$(yq --raw-output ".ui.auth_provider // \"$SYNCMASTER__UI__AUTH_PROVIDER_DEFAULT\"" "$SYNCMASTER_CONFIG_FILE")
18+
else
19+
SYNCMASTER__UI__AUTH_PROVIDER="$SYNCMASTER__UI__AUTH_PROVIDER_DEFAULT"
20+
fi
21+
fi
22+
323
cat <<EOF > /usr/share/nginx/html/env-config.js
424
window.env = {
525
API_URL: "${SYNCMASTER__UI__API_BROWSER_URL}",
@@ -9,4 +29,4 @@ EOF
929

1030
sed -i '/<\/head>/i \ <script src="/env-config.js"></script>' /usr/share/nginx/html/index.html
1131

12-
exec "$@"
32+
exec "$@"

0 commit comments

Comments
 (0)