Dockerfile and Nginx config to setup really basic statics file hosting container.

This setup will let host do all the HTTPS, GZIP, cache etc magic.

Dockerfile

# Use nginx:alpine as base image
FROM nginx:alpine

# Copy static files into Nginx webroot
COPY ./public /usr/share/nginx/html
# Copy custom Nginx config to Docker container
COPY ./nginx.conf /etc/nginx/conf.d/default.conf

# Expose port 80 let host handle HTTPS etc
EXPOSE 80

nginx.conf

server {
  # Set Nginx to listen on port 80
  listen 80 default_server;
  listen [::]:80 default_server;

  # Set webroot (where files will be)
  root /usr/share/nginx/html;
  # If no exact filename given default to index.html
  index index.html;

  # Set 404 error page to custom file
  # Custom 404 path from "root"
  error_page 404 /404.html;
  # Fall to custom 404 when no files or folders found
  location / {
    try_files $uri $uri/ =404;
  }
}