Skip to content

Instantly share code, notes, and snippets.

@pumano
Created November 2, 2018 10:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pumano/58a138c22c142e0eee5003abf1f49e0d to your computer and use it in GitHub Desktop.
Save pumano/58a138c22c142e0eee5003abf1f49e0d to your computer and use it in GitHub Desktop.
Angular + Nginx + Docker = Production
node_modules
dist
version: '3.1'
services:
frontend:
build: .
ports:
- 80:80
######################### BUILD ########################
FROM node:10 as build-stage
WORKDIR /app
COPY package*.json /app/
RUN npm install
COPY . /app
RUN npm run build:prod
###################### DEPLOY ###########################
FROM nginx:alpine
## Remove default nginx website
RUN rm -rf /usr/share/nginx/html/*
## Copy all needed files to
COPY --from=build-stage /app/dist/app /usr/share/nginx/html
# Copy the default nginx.conf if needed
COPY --from=build-stage /app/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
include /etc/nginx/mime.types;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
location / {
try_files $uri $uri/ /index.html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment