Minifier le contenue d'Hugo

Contenu

Apres Comment j’ai virer mon wordpress pour GoHugo, voici comment y aporter quelque optimisations, au niveau docker et du contenue generer

Build

L’image Docker

FROM alpine:3.7

ARG HUGO_VERSION
ARG MINIFY_VERSION

# Install HUGO
RUN set -x && \
  apk add --update curl ca-certificates && \
  curl -L https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_Linux-64bit.tar.gz | tar -xz hugo -C /usr/local/bin && \
  curl -L https://bin.equinox.io/c/dhgbqpS8Bvy/minify-stable-linux-amd64.tgz | tar -xz minify -C /usr/local/bin && \
  rm /var/cache/apk/*

Les variables

La CI

image: docker:latest

services:
  - docker:dind

before_script:
  - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY

build-master:
  stage: build
  script:
    - docker build --pull
      --build-arg HUGO_VERSION="${HUGO_VERSION}"
      --build-arg MINIFY_VERSION="${MINIFY_VERSION}"
      -t "$CI_REGISTRY_IMAGE" .

    - docker tag  "${CI_REGISTRY_IMAGE}" "${CI_REGISTRY_IMAGE}:${HUGO_VERSION}"
    - docker push "${CI_REGISTRY_IMAGE}"
    - docker push "${CI_REGISTRY_IMAGE}:${HUGO_VERSION}"

  only:
    - master

build:
  stage: build
  script:
    - docker build --pull
      --build-arg HUGO_VERSION="${HUGO_VERSION}"
      -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .

    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
  except:
    - master

Deploiement Hugo

image: ${CI_REGISTRY}/github/hugo-build:latest

variables:
  GIT_SUBMODULE_STRATEGY: recursive

pages:
  script:
  - hugo
  - minify -r -o public/ public/
  artifacts:
    paths:
    - public
  only:
  - master

test:
  script:
  - hugo
  except:
  - master

Pascal
How To   Hugo   Docker   Gitlab   Gitlab CI   Minifier  

comments powered by Disqus