Skip to content

Commit

Permalink
Add Docker static site containerisation
Browse files Browse the repository at this point in the history
This change adds Docker containerisation utilising a multi-stage build
Dockerfile. This leads to the static site being generated and served
through nginx.
  • Loading branch information
LiamMacP committed Oct 18, 2023
1 parent c15b21d commit f8a21f4
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
version: 2
updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "docker"
labels:
- "dependencies"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
interval: "daily"
commit-message:
prefix: "github-actions"
labels:
Expand Down
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:18.18.0-alpine AS build

COPY . .

RUN apk update && apk upgrade && \
apk add --no-cache git

RUN npm ci --omit=dev
RUN npm run build

FROM nginx:1.25.2-alpine

COPY --from=build /_site /usr/share/nginx/html
COPY --from=build /nginx/nginx.conf /etc/nginx/nginx.conf

USER 1000

CMD ["/usr/sbin/nginx", "-g", "daemon off;"]
47 changes: 47 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /tmp/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"';

access_log /var/log/nginx/access.log main;

sendfile on;

keepalive_timeout 10;
send_timeout 10;
server_tokens off;
client_body_timeout 10;
client_header_timeout 10;
client_max_body_size 100K;

server {
listen 80;
root /usr/share/nginx/html;

location / {
try_files $uri $uri/ $uri.html =404;
}

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
}

client_body_temp_path /tmp/client_temp;
proxy_temp_path /tmp/proxy_temp_path;
fastcgi_temp_path /tmp/fastcgi_temp;
uwsgi_temp_path /tmp/uwsgi_temp;
scgi_temp_path /tmp/scgi_temp;

}

0 comments on commit f8a21f4

Please sign in to comment.