Browse Source

Add docker

master
Chris Smith 5 years ago
parent
commit
2e4aa0019c
2 changed files with 100 additions and 0 deletions
  1. 27
    0
      Dockerfile
  2. 73
    0
      nginx.conf

+ 27
- 0
Dockerfile View File

@@ -0,0 +1,27 @@
1
+##
2
+## Step 1 - add content and build with Hugo
3
+##
4
+
5
+FROM debian:stretch as hugo
6
+RUN apt-get -qq update \
7
+	&& DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends python-pygments git ca-certificates asciidoctor \
8
+	&& rm -rf /var/lib/apt/lists/*
9
+
10
+ENV HUGO_VERSION 0.53
11
+ENV HUGO_BINARY hugo_${HUGO_VERSION}_Linux-64bit.deb
12
+
13
+ADD https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/${HUGO_BINARY} /tmp/hugo.deb
14
+RUN dpkg -i /tmp/hugo.deb \
15
+	&& rm /tmp/hugo.deb
16
+
17
+ADD . /tmp/site
18
+RUN hugo -b https://kb.chameth.com/ -v -s /tmp/site -d /tmp/hugo && \
19
+	cp /tmp/hugo/index.xml /tmp/hugo/feed.xml
20
+
21
+##
22
+## Step 3 - host!
23
+##
24
+
25
+FROM nginx:mainline-alpine AS nginx
26
+COPY --from=hugo /tmp/site /usr/share/nginx/html
27
+ADD nginx.conf /etc/nginx/nginx.conf

+ 73
- 0
nginx.conf View File

@@ -0,0 +1,73 @@
1
+user  nginx;
2
+worker_processes  1;
3
+
4
+error_log  /var/log/nginx/error.log warn;
5
+pid        /var/run/nginx.pid;
6
+
7
+
8
+events {
9
+    worker_connections  1024;
10
+}
11
+
12
+
13
+http {
14
+    include       /etc/nginx/mime.types;
15
+    default_type  application/octet-stream;
16
+
17
+    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
18
+                      '$status $body_bytes_sent "$http_referer" '
19
+                      '"$http_user_agent" "$http_x_forwarded_for"';
20
+
21
+    access_log  /var/log/nginx/access.log  main;
22
+
23
+    sendfile        on;
24
+
25
+    keepalive_timeout  65;
26
+
27
+    server_tokens off;
28
+
29
+    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
30
+    add_header Content-Security-Policy "default-src 'none'; script-src 'self'; img-src 'self'; style-src 'self'; font-src 'self'; frame-ancestors 'none'; form-action 'none'; base-uri 'none';";
31
+    add_header X-Frame-Options "SAMEORIGIN";
32
+    add_header X-Content-Type-Options "nosniff";
33
+    add_header X-XSS-Protection "1; mode=block";
34
+    add_header Expect-CT "enforce; max-age=3600";
35
+    add_header Referrer-Policy "no-referrer";
36
+
37
+    gzip on;
38
+    gzip_vary on;
39
+    gzip_proxied any;
40
+    gzip_comp_level 6;
41
+    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
42
+
43
+    map $http_accept $webp_suffix {
44
+        "~*webp"  ".webp";
45
+    }
46
+
47
+    server {
48
+        listen       80;
49
+        server_name  localhost;
50
+
51
+        location / {
52
+            root   /usr/share/nginx/html;
53
+            index  index.html index.htm;
54
+
55
+            location /res {
56
+                expires 1y;
57
+            }
58
+
59
+            location ~ \.(png|jpe?g)$ {
60
+                try_files $uri$webp_suffix $uri =404;
61
+                expires 1y;
62
+            }
63
+        }
64
+
65
+        #error_page  404              /404.html;
66
+
67
+        error_page   500 502 503 504  /50x.html;
68
+        location = /50x.html {
69
+            root   /usr/share/nginx/html;
70
+        }
71
+    }
72
+
73
+}

Loading…
Cancel
Save