Ver código fonte

New docker files.

Split the build up into multiple stages:

 1) Hugo
 2) Minfy
 3) Serve

This means nginx is serving instead of hugo, and there are
no random apps installed in the end container.
master
Chris Smith 6 anos atrás
pai
commit
d1f3b42cdf

+ 45
- 1
Dockerfile Ver arquivo

@@ -1,2 +1,46 @@
1
-FROM publysher/hugo
1
+##
2
+## Step 1 - add content and build with Hugo
3
+##
2 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 asciidoc \
8
+	&& rm -rf /var/lib/apt/lists/*
9
+
10
+ENV HUGO_VERSION 0.22.1
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
+ARG baseurl=https://www.chameth.com/
18
+
19
+USER nobody:nogroup
20
+ADD site /tmp/site
21
+RUN hugo -b $baseurl -v -s /tmp/site -d /tmp/hugo && \
22
+	cp /tmp/hugo/index.xml /tmp/hugo/feed.xml
23
+
24
+##
25
+## Step 2 - compress, minify, etc
26
+##
27
+
28
+FROM debian:stretch as minify
29
+RUN apt-get update \
30
+    && DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends yui-compressor tidy \
31
+	&& rm -rf /var/lib/apt/lists/*
32
+
33
+COPY --from=hugo /tmp/hugo /tmp/site
34
+ADD minify.sh /tmp/minify.sh
35
+
36
+RUN chown -R nobody:nogroup /tmp/site && chmod +x /tmp/minify.sh
37
+USER nobody:nogroup
38
+RUN /tmp/minify.sh
39
+
40
+##
41
+## Step 3 - host!
42
+##
43
+
44
+FROM nginx:mainline-alpine AS nginx
45
+COPY --from=minify /tmp/site /usr/share/nginx/html
46
+ADD nginx.conf /etc/nginx/conf.d/site.conf

+ 4
- 10
docker-compose.dev.yml Ver arquivo

@@ -4,17 +4,11 @@ version: '2'
4 4
 
5 5
 services:
6 6
   hugo:
7
-    build: .
7
+    build:
8
+      context: .
9
+      args:
10
+        baseurl: https://dev.chameth.com/
8 11
     restart: always
9 12
     labels:
10 13
       com.chameth.vhost: 'dev.chameth.com'
11 14
       com.chameth.proxy: '1313'
12
-    command:
13
-      - hugo
14
-      - server
15
-      - --bind=0.0.0.0
16
-      - --port=1313
17
-      - --baseURL=https://dev.chameth.com/
18
-      - --appendPort=false
19
-      - --disableLiveReload
20
-      - --log

+ 0
- 9
docker-compose.yml Ver arquivo

@@ -9,12 +9,3 @@ services:
9 9
     labels:
10 10
       com.chameth.vhost: 'chameth.com,www.chameth.com'
11 11
       com.chameth.proxy: '1313'
12
-    command:
13
-      - hugo
14
-      - server
15
-      - --bind=0.0.0.0
16
-      - --port=1313
17
-      - --baseURL=https://www.chameth.com/
18
-      - --appendPort=false
19
-      - --disableLiveReload
20
-      - --log

+ 23
- 0
minify.sh Ver arquivo

@@ -0,0 +1,23 @@
1
+#!/bin/bash
2
+
3
+set -uxeo pipefail
4
+
5
+# Compress all the CSS files together
6
+cat /tmp/site/res/css/*.css > "/tmp/css-concatted.css"
7
+yui-compressor "/tmp/css-concatted.css" > "/tmp/css-combined.css"
8
+
9
+# Generate a small hash to bust caches if the file changes
10
+HASH=`sha256sum /tmp/css-combined.css | cut -c -10`
11
+
12
+# Replace the old CSS with the new
13
+mv "/tmp/css-combined.css" "/tmp/site/res/stylesheet-$HASH.css"
14
+rm -rf "/tmp/site/res/css"
15
+
16
+# Replace the references in the HTML, then run tidy over it
17
+for file in $(find /tmp/site/ -name '*.html'); do
18
+	sed -i "s#\"/res/css/style.css\"#\"/res/stylesheet-$HASH.css\"#g" "$file"
19
+	sed -i '\#"/res/css/.*.css"#d' "$file"
20
+
21
+	# Tidy exits if there are warnings, which there probably will be...
22
+	tidy -q -i -w 120 -m --vertical-space yes --drop-empty-elements no "$file" || true
23
+done

+ 10
- 0
nginx.conf Ver arquivo

@@ -0,0 +1,10 @@
1
+server_tokens off;
2
+
3
+add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
4
+add_header Content-Security-Policy "default-src 'none'; script-src 'none'; img-src 'self' https://photos.chameth.com; style-src 'self'; font-src 'self';";
5
+add_header X-Frame-Options "SAMEORIGIN";
6
+add_header X-Content-Type-Options "nosniff";
7
+add_header X-XSS-Protection "1; mode=block";
8
+add_header Expect-CT "enforce; max-age=3600";
9
+
10
+gzip on;

+ 1
- 1
site/static/res/css/font-awesome.min.css
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 1
- 1
site/static/res/css/lightbox.min.css Ver arquivo

@@ -1 +1 @@
1
-.lb-loader,.lightbox{text-align:center;line-height:0}body:after{content:url(../images/close.png) url(../images/loading.gif) url(../images/prev.png) url(../images/next.png);display:none}.lb-dataContainer:after,.lb-outerContainer:after{content:"";clear:both}body.lb-disable-scrolling{overflow:hidden}.lightboxOverlay{position:absolute;top:0;left:0;z-index:9999;background-color:#000;filter:alpha(Opacity=80);opacity:.8;display:none}.lightbox{position:absolute;left:0;width:100%;z-index:10000;font-weight:400}.lightbox .lb-image{display:block;height:auto;max-width:inherit;border-radius:3px}.lightbox a img{border:none}.lb-outerContainer{position:relative;background-color:#fff;width:250px;height:250px;margin:0 auto;border-radius:4px}.lb-loader,.lb-nav{position:absolute;left:0}.lb-outerContainer:after{display:table}.lb-container{padding:4px}.lb-loader{top:43%;height:25%;width:100%}.lb-cancel{display:block;width:32px;height:32px;margin:0 auto;background:url(../images/loading.gif) no-repeat}.lb-nav{top:0;height:100%;width:100%;z-index:10}.lb-container>.nav{left:0}.lb-nav a{outline:0;background-image:url(data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)}.lb-next,.lb-prev{height:100%;cursor:pointer;display:block}.lb-nav a.lb-prev{width:34%;left:0;float:left;background:url(../images/prev.png) left 48% no-repeat;filter:alpha(Opacity=0);opacity:0;-webkit-transition:opacity .6s;-moz-transition:opacity .6s;-o-transition:opacity .6s;transition:opacity .6s}.lb-nav a.lb-prev:hover{filter:alpha(Opacity=100);opacity:1}.lb-nav a.lb-next{width:64%;right:0;float:right;background:url(../images/next.png) right 48% no-repeat;filter:alpha(Opacity=0);opacity:0;-webkit-transition:opacity .6s;-moz-transition:opacity .6s;-o-transition:opacity .6s;transition:opacity .6s}.lb-nav a.lb-next:hover{filter:alpha(Opacity=100);opacity:1}.lb-dataContainer{margin:0 auto;padding-top:5px;width:100%;-moz-border-radius-bottomleft:4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomright:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px}.lb-dataContainer:after{display:table}.lb-data{padding:0 4px;color:#ccc}.lb-data .lb-details{width:85%;float:left;text-align:left;line-height:1.1em}.lb-data .lb-caption{font-size:13px;font-weight:700;line-height:1em}.lb-data .lb-number{display:block;clear:left;padding-bottom:1em;font-size:12px;color:#999}.lb-data .lb-close{display:block;float:right;width:30px;height:30px;background:url(../images/close.png) top right no-repeat;text-align:right;outline:0;filter:alpha(Opacity=70);opacity:.7;-webkit-transition:opacity .2s;-moz-transition:opacity .2s;-o-transition:opacity .2s;transition:opacity .2s}.lb-data .lb-close:hover{cursor:pointer;filter:alpha(Opacity=100);opacity:1}
1
+.lb-loader,.lightbox{text-align:center;line-height:0}body:after{content:url(/res/images/close.png) url(/res/images/loading.gif) url(/res/images/prev.png) url(/res/images/next.png);display:none}.lb-dataContainer:after,.lb-outerContainer:after{content:"";clear:both}body.lb-disable-scrolling{overflow:hidden}.lightboxOverlay{position:absolute;top:0;left:0;z-index:9999;background-color:#000;filter:alpha(Opacity=80);opacity:.8;display:none}.lightbox{position:absolute;left:0;width:100%;z-index:10000;font-weight:400}.lightbox .lb-image{display:block;height:auto;max-width:inherit;border-radius:3px}.lightbox a img{border:none}.lb-outerContainer{position:relative;background-color:#fff;width:250px;height:250px;margin:0 auto;border-radius:4px}.lb-loader,.lb-nav{position:absolute;left:0}.lb-outerContainer:after{display:table}.lb-container{padding:4px}.lb-loader{top:43%;height:25%;width:100%}.lb-cancel{display:block;width:32px;height:32px;margin:0 auto;background:url(/res/images/loading.gif) no-repeat}.lb-nav{top:0;height:100%;width:100%;z-index:10}.lb-container>.nav{left:0}.lb-nav a{outline:0;background-image:url(data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)}.lb-next,.lb-prev{height:100%;cursor:pointer;display:block}.lb-nav a.lb-prev{width:34%;left:0;float:left;background:url(/res/images/prev.png) left 48% no-repeat;filter:alpha(Opacity=0);opacity:0;-webkit-transition:opacity .6s;-moz-transition:opacity .6s;-o-transition:opacity .6s;transition:opacity .6s}.lb-nav a.lb-prev:hover{filter:alpha(Opacity=100);opacity:1}.lb-nav a.lb-next{width:64%;right:0;float:right;background:url(/res/images/next.png) right 48% no-repeat;filter:alpha(Opacity=0);opacity:0;-webkit-transition:opacity .6s;-moz-transition:opacity .6s;-o-transition:opacity .6s;transition:opacity .6s}.lb-nav a.lb-next:hover{filter:alpha(Opacity=100);opacity:1}.lb-dataContainer{margin:0 auto;padding-top:5px;width:100%;-moz-border-radius-bottomleft:4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomright:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px}.lb-dataContainer:after{display:table}.lb-data{padding:0 4px;color:#ccc}.lb-data .lb-details{width:85%;float:left;text-align:left;line-height:1.1em}.lb-data .lb-caption{font-size:13px;font-weight:700;line-height:1em}.lb-data .lb-number{display:block;clear:left;padding-bottom:1em;font-size:12px;color:#999}.lb-data .lb-close{display:block;float:right;width:30px;height:30px;background:url(/res/images/close.png) top right no-repeat;text-align:right;outline:0;filter:alpha(Opacity=70);opacity:.7;-webkit-transition:opacity .2s;-moz-transition:opacity .2s;-o-transition:opacity .2s;transition:opacity .2s}.lb-data .lb-close:hover{cursor:pointer;filter:alpha(Opacity=100);opacity:1}

+ 12
- 14
site/static/res/css/style.css Ver arquivo

@@ -1,9 +1,7 @@
1
-@import url("font-awesome.min.css");
2
-
3 1
 @font-face {
4 2
     font-family: 'Aileron Regular';
5
-    src: url('../fonts/aileron-regular-webfont.woff2') format('woff2'),
6
-         url('../fonts/aileron-regular-webfont.woff') format('woff');
3
+    src: url('/res/fonts/aileron-regular-webfont.woff2') format('woff2'),
4
+         url('/res/fonts/aileron-regular-webfont.woff') format('woff');
7 5
     font-weight: normal;
8 6
     font-style: normal;
9 7
 
@@ -11,12 +9,12 @@
11 9
 
12 10
 @font-face {
13 11
     font-family: 'League Spartan';
14
-    src: url('../fonts/leaguespartan-bold.eot');
15
-    src: url('../fonts/leaguespartan-bold.eot?#iefix') format('embedded-opentype'),
16
-         url('../fonts/leaguespartan-bold.woff2') format('woff2'),
17
-         url('../fonts/leaguespartan-bold.woff') format('woff'),
18
-         url('../fonts/leaguespartan-bold.ttf') format('truetype'),
19
-         url('../fonts/leaguespartan-bold.svg#league_spartanbold') format('svg');
12
+    src: url('/res/fonts/leaguespartan-bold.eot');
13
+    src: url('/res/fonts/leaguespartan-bold.eot?#iefix') format('embedded-opentype'),
14
+         url('/res/fonts/leaguespartan-bold.woff2') format('woff2'),
15
+         url('/res/fonts/leaguespartan-bold.woff') format('woff'),
16
+         url('/res/fonts/leaguespartan-bold.ttf') format('truetype'),
17
+         url('/res/fonts/leaguespartan-bold.svg#league_spartanbold') format('svg');
20 18
     font-weight: bold;
21 19
     font-style: normal;
22 20
 }
@@ -2079,7 +2077,7 @@ article img {
2079 2077
       -webkit-transition: opacity 0.2s ease-in-out;
2080 2078
       -ms-transition: opacity 0.2s ease-in-out;
2081 2079
       transition: opacity 0.2s ease-in-out;
2082
-      background: url("../images/overlay.png");
2080
+      background: url("/res/images/overlay.png");
2083 2081
       border-radius: 0.35em;
2084 2082
       content: '';
2085 2083
       display: block;
@@ -2124,7 +2122,7 @@ article img {
2124 2122
       }
2125 2123
 
2126 2124
       .image.thumb:hover:before {
2127
-        background: url("../images/overlay.png"), url("../images/overlay.png");
2125
+        background: url("/res/images/overlay.png"), url("/res/images/overlay.png");
2128 2126
         opacity: 1.0;
2129 2127
       }
2130 2128
 
@@ -2566,7 +2564,7 @@ article img {
2566 2564
     justify-content: space-between;
2567 2565
     background-color: #1f1815;
2568 2566
     background-attachment: scroll,                fixed;
2569
-    background-image: url("../images/overlay.png"), url("../images/background.jpg");
2567
+    background-image: url("/res/images/overlay.png"), url("/res/images/background.jpg");
2570 2568
     background-position: top left,              top left;
2571 2569
     background-repeat: repeat,                no-repeat;
2572 2570
     background-size: auto,                auto 100%;
@@ -3066,7 +3064,7 @@ article img {
3066 3064
       #footer {
3067 3065
         background-attachment: scroll;
3068 3066
         background-color: #1f1815;
3069
-        background-image: url("../images/overlay.png"), url("../images/background.jpg");
3067
+        background-image: url("/res/images/overlay.png"), url("/res/images/background.jpg");
3070 3068
         background-position: top left,            bottom center;
3071 3069
         background-repeat: repeat,              no-repeat;
3072 3070
         background-size: auto,              cover;

Carregando…
Cancelar
Salvar