Skip to content

Instantly share code, notes, and snippets.

@AZagatti
Created July 27, 2020 12:43
Show Gist options
  • Save AZagatti/343a8fb6a278f38c291f6091970f98a5 to your computer and use it in GitHub Desktop.
Save AZagatti/343a8fb6a278f38c291f6091970f98a5 to your computer and use it in GitHub Desktop.
Server config
.git
build
node_modules
.env
docker-compose.yml
Dockerfile
./certs
version: '3.6'
services:
nginx:
build: '.'
ports:
- '80:80'
- '443:443'
restart: 'always'
environment:
- 'NODE_ENV=production'
volumes:
- ./cert:/etc/nginx/ssl
FROM node:alpine as build
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn install
COPY . .
# Change command to run build
RUN yarn build:web
FROM nginx:stable-alpine
# Change the build output dir
COPY --from=build /usr/src/app/web-build /usr/share/nginx/html
COPY --from=build /usr/src/app/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
EXPOSE 443
CMD ["nginx", "-g", "daemon off;"]
server {
listen 80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/public.crt;
ssl_certificate_key /etc/nginx/ssl/private.key;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
include /etc/nginx/extra-conf.d/*.conf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment