Verified Commit d30fcea2 authored by Sandro Lutz's avatar Sandro Lutz
Browse files

Add Dockerfile and nginx configuration

parent 71b9ae6f
# This Dockerfile uses a multi-stage build. Only the first stage requires
# all dependencies, the final image will contain only the output files
# First stage: Build project
FROM node:13 as build
# Copy files and install dependencies
COPY ./ /gatsby/
WORKDIR /gatsby
# Install needed libraries
RUN apt-get update && apt-get install -y libgl1-mesa-glx
# Install dependencies
RUN npm install && \
npm audit fix
RUN npm install -g gatsby-cli
# Build project
RUN npm run build
# Second stage: Server to deliver files
FROM nginx:1.15-alpine
# Copy files from first stage
COPY --from=build /gatsby/public /var/www
# Copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /var/www/;
index index.html;
access_log /dev/stdout;
error_log /dev/stderr error;
autoindex off;
error_page 404 /en/404/index.html;
gzip_static on;
gunzip on;
location = /sw.js {
# Do not allow caching of service worker.
add_header Cache-Control "no-cache";
}
location ~* /(en|de)/404/index.html {
internal;
}
location ~* \.html$ {
add_header Cache-Control "no-cache";
expires off;
}
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|jsx|css|less|swf|eot|ttf|otf|woff|woff2)$ {
add_header Cache-Control "public";
expires +1y;
}
location ~* ^/(en|de)/ {
error_page 404 /$1/404/index.html;
try_files $uri $uri/index.html =404;
}
location / {
error_page 404 /en/404/index.html;
try_files $uri $uri/index.html =404;
}
# location ~* ^/(en|de)/(events|jobs|studydocuments) {
# try_files $uri /$1/events/index.html
# }
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment