Skip to content

Instantly share code, notes, and snippets.

@bastienapp
Last active July 26, 2023 17:23
Show Gist options
  • Save bastienapp/afef8b6315628411582b45e8d04143f4 to your computer and use it in GitHub Desktop.
Save bastienapp/afef8b6315628411582b45e8d04143f4 to your computer and use it in GitHub Desktop.
Docker deployment: Angular
# default.conf
server {
listen 4200;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
# Dockerfile frontend
# build environment
FROM node:lts-slim as build
WORKDIR /build
COPY . .
ENV PATH ./node_modules/.bin:$PATH
RUN npm ci
RUN ng build --configuration production --output-path=dist
# production environment
FROM nginx:stable-alpine-slim
COPY --from=build /build/dist/ /usr/share/nginx/html
COPY default.conf /etc/nginx/conf.d/
EXPOSE 4200
CMD ["nginx", "-g", "daemon off;"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment