Skip to content

Instantly share code, notes, and snippets.

@SkYNewZ
Last active October 28, 2021 19:15
Show Gist options
  • Save SkYNewZ/0a0e1b32f91ea09efa1f5bdfef480b21 to your computer and use it in GitHub Desktop.
Save SkYNewZ/0a0e1b32f91ea09efa1f5bdfef480b21 to your computer and use it in GitHub Desktop.
Dockerfile
FROM node:16 as builder
ENV NODE_ENV production
WORKDIR /usr/src/app
# Deps
COPY package.json yarn.lock ./
RUN yarn install \
--emoji false \
--no-progress \
--frozen-lockfile \
--prefer-offline \
--pure-lockfile \
--non-interactive \
--production=true
# App
COPY . .
RUN yarn generate --fail-on-error
FROM docker.io/nginxinc/nginx-unprivileged:1.20-alpine as runner
COPY nginx/server.conf /etc/nginx/conf.d/default.conf
COPY --from=builder --chown=101:101 /usr/src/app/dist /usr/share/nginx/html
ENTRYPOINT ["nginx", "-g", "daemon off;"]
server {
listen 8080;
server_name _;
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
gzip_min_length 1000;
charset utf-8;
server_tokens off;
root /usr/share/nginx/html;
location /robots.txt {
return 200 "User-agent: *\nDisallow: /";
}
location ~* \.(?:ico|gif|jpe?g|png|woff2?|eot|otf|ttf|svg|js|css)$ {
add_header Pragma public;
add_header Cache-Control "public";
}
location / {
add_header Content-Security-Policy "default-src 'self' 'unsafe-inline';";
add_header X-Content-Type-Options nosniff;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
add_header X-Frame-Options "SAMEORIGIN";
try_files $uri $uri/index.html $uri/index.htm;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment