Skip to content

Instantly share code, notes, and snippets.

@dahoba
Last active August 22, 2019 07:16
Show Gist options
  • Save dahoba/4485946feffd7de69cd93493f3ff0fa7 to your computer and use it in GitHub Desktop.
Save dahoba/4485946feffd7de69cd93493f3ff0fa7 to your computer and use it in GitHub Desktop.
Dockerfile for nodejs compile angular then serve with nginx (alpine linux)
FROM node:10-alpine as builder
WORKDIR /front
COPY package*.json /front/
RUN npm i \
&& mkdir /ng-app \
&& mv ./node_modules /ng-app/
WORKDIR /ng-app
COPY . .
RUN npm run build-docker
#stage 2
FROM nginx:1.16-alpine
# server {
# listen 80;
# sendfile on;
# default_type application/octet-stream;
# gzip on;
# gzip_http_version 1.1;
# gzip_disable "MSIE [1-6]\.";
# gzip_min_length 1100;
# gzip_vary on;
# 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;
# gzip_comp_level 9;
# root /usr/share/nginx/html;
# location / {
# try_files $uri $uri/ /index.html;
# }
# }
COPY docker/nginx-default.conf /etc/nginx/conf.d/default.conf
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /ng-app/dist /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment