Last active
February 24, 2024 16:51
-
-
Save georgelviv/2800828bac48b3bfa5541f2b6fc0990b to your computer and use it in GitHub Desktop.
Dockerfile for Angular app with dynamic env variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM node:20-slim As builder | |
| RUN apt-get update | |
| RUN apt-get install -y python3 | |
| RUN mkdir /frontend | |
| WORKDIR /frontend | |
| RUN npm install -g @angular/cli@16 | |
| COPY package.json package-lock.json ./ | |
| RUN npm ci | |
| COPY . . | |
| RUN npm run build:prod | |
| FROM nginx:1.25.4-alpine | |
| RUN mkdir /frontend | |
| WORKDIR /frontend | |
| COPY --from=builder /frontend/dist /usr/share/nginx/html | |
| COPY --from=builder /frontend/scripts/generate-config.sh /frontend/generate-config.sh | |
| COPY ./configs/nginx.conf /etc/nginx/nginx.conf | |
| RUN chmod +x ./generate-config.sh | |
| RUN apk add --no-cache --upgrade bash | |
| EXPOSE 80 | |
| CMD ./generate-config.sh && mv ./config.json /usr/share/nginx/html/configs/config.json && nginx -g 'daemon off;' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment