diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..01358a7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +# By default, ignore everything +* + +# Blog source +!archetypes/ +!content/ +!data/ +!layouts/ +!resources/ +!static/ +!themes/ +!config.yaml + +# Nginx config file +!nginx.conf diff --git a/.woodpecker.yml b/.woodpecker.yml index 72b3a44..2e3c0c2 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,17 +1,27 @@ pipeline: - build: - image: alpine:3 - commands: - - apk update - - apk add --no-cache hugo - - hugo --minify + # build: + # image: alpine:3 + # commands: + # - apk update + # - apk add --no-cache hugo + # - hugo --minify - deploy: - image: alpine:3 - commands: - - apk update - - apk add --no-cache rsync openssh-client - - eval $(ssh-agent) - - echo "$DEPLOY_KEY" | ssh-add - - - rsync -e "ssh -p $DEPLOY_PORT -o 'StrictHostKeyChecking=no'" -az --delete public/ "$DEPLOY_DEST" - secrets: [ deploy_key, deploy_port, deploy_dest ] + # deploy: + # image: alpine:3 + # commands: + # - apk update + # - apk add --no-cache rsync openssh-client + # - eval $(ssh-agent) + # - echo "$DEPLOY_KEY" | ssh-add - + # - rsync -e "ssh -p $DEPLOY_PORT -o 'StrictHostKeyChecking=no'" -az --delete public/ "$DEPLOY_DEST" + # secrets: [ deploy_key, deploy_port, deploy_dest ] + publish: + image: plugins/docker + repo: chewingbever/blog + tag: [ latest ] + secrets: + - docker_username + - docker_password + when: + branch: master + event: push diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d1cd8f8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM alpine:latest AS builder + +WORKDIR /usr/src/app + +# Install Hugo +RUN apk add --no-cache hugo + +# Copy site files for building +COPY . ./ + +# Generate the site +RUN hugo --minify + + +FROM nginx:alpine + +COPY nginx.conf /etc/nginx/nginx.conf +COPY --from=builder /usr/src/app/public /usr/share/nginx/html diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..f2fdd0d --- /dev/null +++ b/nginx.conf @@ -0,0 +1,26 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + # https://stackoverflow.com/a/51360290/6483444 + map $sent_http_content_type $expires { + default off; + text/html epoch; + text/css max; + application/javascript max; + ~image/ max; + } + + server { + server_name _; + listen 80; + + root /usr/share/nginx/html; + index index.html; + include mime.types; + expires $expires; + } +}