docker image support

This commit is contained in:
Paolo Asperti 2023-12-01 22:17:06 +01:00
parent 14c54c1383
commit 042c206885
Signed by: paspo
GPG Key ID: 06D46905D19D5182
4 changed files with 59 additions and 0 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
public/
resources/
.hugo_build.lock

33
Dockerfile Normal file
View File

@ -0,0 +1,33 @@
FROM debian:stable-slim AS hugobuild
RUN \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --assume-yes wget ca-certificates && \
wget -O /tmp/hugo.deb https://github.com/gohugoio/hugo/releases/download/v0.120.4/hugo_extended_0.120.4_linux-amd64.deb && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --assume-yes /tmp/hugo.deb
COPY . /src
RUN \
hugo -s /src --gc --minify
FROM alpine:latest
RUN \
apk -U upgrade && \
apk add nginx curl && \
mkdir -p /wwwroot /logs
COPY docker/rootfs /
COPY --from=hugobuild /src/public /wwwroot/
RUN \
chown -R nginx:www-data /wwwroot /logs && \
chmod -R a-x,a=rX,ug+w /wwwroot /logs
# config test
RUN nginx -t
HEALTHCHECK --timeout=10s CMD curl --silent --fail -o /dev/null http://127.0.0.1:80/
ENTRYPOINT [ "/usr/sbin/nginx" ]

View File

@ -0,0 +1 @@
daemon off;

View File

@ -0,0 +1,22 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
access_log /logs/nginx.access.log main;
sendfile off;
root /wwwroot;
index index.html;
location = /404.html {
internal;
}
}
gzip on;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js image/x-icon font/woff2 font/woff application/x-font-woff;
gzip_disable "msie6";
etag on;
if_modified_since exact;
add_header Pragma "public";
add_header Cache-Control "max-age=31536000, public";