From bb3e163957941ca2caa3527b8a5073f6ccbd5bcc Mon Sep 17 00:00:00 2001 From: Ariejan de Vroom Date: Wed, 8 Mar 2023 21:34:24 +0100 Subject: [PATCH] Move to dockerized dokku deployment --- .gitlab-ci.yml | 32 ++++++++++++-------------------- Dockerfile | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 Dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 09b568a..9f2c80e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,23 +1,15 @@ -image: registry.gitlab.com/pages/hugo/hugo_extended:latest +stages: + - deploy -variables: - GIT_SUBMODULE_STRATEGY: recursive - -pages: - before_script: - - apk add --no-cache imagemagick - script: - - hugo - - ls -lah - - find ./public -name '*.jpg' -exec mogrify -auto-orient -monitor -sampling-factor 4:2:0 -strip -interlace JPEG -colorspace sRGB -resize 2048 -compress JPEG -quality 80 {} \; - artifacts: - paths: - - public +deploy: + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + image: ilyasemenov/gitlab-ci-git-push + stage: deploy + environment: + name: production + url: https://www.devroom.io only: - - master - -test: + - master script: - - hugo - except: - - master + - git-push ssh://dokku@9up.nl:22/devroom.io diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cc79367 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +## `source` is used to generate the static HTML with Hugo +FROM debian:11 as source + +# Install dependencies +RUN apt-get update && \ + apt-get install -y imagemagick ca-certificates git wget + +# Install Hugo +ENV HUGO_VERSION 0.111.2 +RUN wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz && \ + tar -xvf hugo_extended_${HUGO_VERSION}_Linux-64bit.tar.gz && \ + mv hugo /usr/local/bin/hugo && \ + chmod +x /usr/local/bin/hugo + +# Copy site source +WORKDIR /src +COPY . . + +# Initialize submodules, like themes +RUN git submodule update --init --recursive + +# Generate the site into /src/public +RUN /usr/local/bin/hugo + +# Mogrify all images to be more efficient for the web +RUN find ./public -name '*.jpg' -exec mogrify -auto-orient -monitor -sampling-factor 4:2:0 -strip -interlace JPEG -colorspace sRGB -resize 2048 -compress JPEG -quality 80 {} \; + +## Create the final image with Nginx serving the static site +FROM nginx:1-alpine +COPY --from=source /src/public /usr/share/nginx/html