Skip to content

Instantly share code, notes, and snippets.

@viktor-shmigol
Created February 22, 2018 10:17
Show Gist options
  • Save viktor-shmigol/f9c9e70973f8177219c61d31c5e6753d to your computer and use it in GitHub Desktop.
Save viktor-shmigol/f9c9e70973f8177219c61d31c5e6753d to your computer and use it in GitHub Desktop.
docker-compose-prod.yml:
```
version: '2'
services:
web:
build:
context: .
dockerfile: ./Dockerfile_prod
command: /bin/bash -c "envsubst '$$NGINX_HOST $$NGINX_PORT' < /etc/nginx/conf.d/angular-seed.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
container_name: angular-seed-prod
image: angular-seed/prod
environment:
- ENV=staging
- NGINX_HOST=localhost
- NGINX_PORT=80
networks:
- prod-network
ports:
- '5555:80'
networks:
prod-network:
driver: bridge
```
Dockerfile_prod:
```
FROM node:8.6 as builder
WORKDIR /home/node/angular-seed
# copy all files not listed in .dockerignore
COPY . .
# before switching to non-root user, change ownership of home
RUN chown -R node:node .
USER node
RUN npm install
RUN ./node_modules/@angular/cli/bin/ng build --prod --env=prod
FROM nginx:1.13
COPY --from=builder /home/node/angular-seed/dist /var/www/dist/prod
COPY ./nginx.conf /etc/nginx/conf.d/angular-seed.template
```
nginx.conf:
```
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen ${NGINX_PORT};
server_name ${NGINX_HOST};
# ssl on;
# ssl_certificate angular-seed_server.crt;
# ssl_certificate_key angular-seed_server.pem;
#
# ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# ssl_prefer_server_ciphers on;
# ssl_session_cache shared:SSL:10m;
# ssl_session_tickets off; # Requires nginx >= 1.5.9
# add_header Strict-Transport-Security "max-age=63072000; preload";
# add_header X-Frame-Options DENY;
#
# location /api/microservice1 {
# rewrite ^/api/microservice1/(.*)$ /$1 break;
# proxy_pass https://microservice1/;
# proxy_http_version 1.1;
# proxy_set_header X-Forwarded-For $remote_addr;
# }
location / {
root /var/www/dist/prod;
try_files $uri /index.html;
index index.html;
gzip on;
gzip_types text/css text/javascript application/x-javascript application/json;
}
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment