Skip to content

Commit

Permalink
Switch from entrypoint to cmd to allow overriding (#249)
Browse files Browse the repository at this point in the history
- Add a script that copies an environment variable `SETTINGS` to the `settings.env.json` file for use as appsettings
- Update Dockerfile to include the script above
- Change the permissions of the `config` directory so that the startup script can write the `settings.env.json` file
  • Loading branch information
sei-ebram authored Jul 22, 2021
1 parent c963f04 commit 1494620
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@ RUN $(npm bin)/ng build --configuration production

FROM nginxinc/nginx-unprivileged:stable-alpine

# Clear all original files
USER root
RUN rm -rf /usr/share/nginx/html/*
USER nginx

COPY default.conf /etc/nginx/conf.d/default.conf
COPY nginx-basehref.sh /docker-entrypoint.d/90-basehref.sh
COPY scripts/settings-from-env.sh /usr/local/bin
COPY scripts/nginx-basehref.sh /docker-entrypoint.d/90-basehref.sh
COPY --from=builder /ng-app/dist /usr/share/nginx/html

USER root
RUN chmod 755 /usr/local/bin/settings-from-env.sh && \
chown nginx:nginx /usr/share/nginx/html/assets/config
USER nginx

EXPOSE 8080

ENTRYPOINT ["nginx", "-g", "daemon off;"]
CMD ["nginx", "-g", "daemon off;"]
File renamed without changes.
4 changes: 4 additions & 0 deletions scripts/settings-from-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -e
echo $SETTINGS > /usr/share/nginx/html/assets/config/settings.env.json
nginx -g "daemon off;"

0 comments on commit 1494620

Please sign in to comment.