Skip to content

Instantly share code, notes, and snippets.

@wodCZ
Created February 13, 2019 14:28
Show Gist options
  • Save wodCZ/d956b59754fb580d38c8a7c040568607 to your computer and use it in GitHub Desktop.
Save wodCZ/d956b59754fb580d38c8a7c040568607 to your computer and use it in GitHub Desktop.
Configuration for SPA frontend in Docker
FROM node:9.8.0-alpine as build
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn
COPY . ./
RUN yarn build
FROM nginx:1.13.9-alpine
COPY ./nginx.conf /etc/nginx/nginx.conf
COPY --from=build /usr/src/app/build /usr/share/nginx/html
user nginx;
worker_processes 1;
error_log /dev/stderr warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
map $status $loggable {
~^[23] 0;
default 1;
}
access_log /dev/stdout main if=$loggable;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
root /usr/share/nginx/html;
index index.html index.htm;
location /service-worker.js {
add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
expires off;
proxy_no_cache 1;
access_log off;
}
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