From 2d42b6a3a298c2a53380a41073aaf185558a05ca Mon Sep 17 00:00:00 2001 From: sthope Date: Mon, 6 Sep 2021 18:18:28 +0200 Subject: [PATCH] initial commit --- .drone.yml | 30 ++++++++++++++++++--------- Dockerfile | 59 ++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 61 insertions(+), 28 deletions(-) diff --git a/.drone.yml b/.drone.yml index 39bba36..13eb9ee 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,12 +1,24 @@ +# kind: pipeline +# name: default + +# steps: +# - name: build +# image: plugins/hugo +# settings: +# hugo_version: 0.88.1 +# pull: always +# validate: true +# config: blog/config.toml +# theme: /drone/src/blog/themes + +--- kind: pipeline -name: default +type: docker steps: -- name: build - image: plugins/hugo - settings: - hugo_version: 0.88.1 - pull: always - validate: true - config: blog/config.toml - theme: /drone/src/blog/themes + - name: test + image: plugins/hugo + settings: + validate: true + pull: always + source: blog/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 73a1002..82538ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,45 @@ -FROM alpine:latest - -LABEL maintainer="Sthope " +# GitHub: https://github.com/gohugoio +# Twitter: https://twitter.com/gohugoio +# Website: https://gohugo.io/ -RUN apk add --no-cache \ - curl \ - git \ - openssh-client \ - rsync \ - build-base \ - libc6-compat +FROM golang:1.16-alpine AS build -RUN HUGO=$(curl -s "https://api.github.com/repos/gohugoio/hugo/releases/latest" | awk -F '"' '/tag_name/{print $4}'| sed -E 's/v//g;') && \ - export HUGO && \ - mkdir -p /usr/local/src && \ - cd /usr/local/src && \ - curl -L "https://github.com/gohugoio/hugo/releases/download/v${HUGO}/hugo_extended_${HUGO}_linux-64bit.tar.gz" | tar -xz && \ - mv hugo /usr/local/bin/hugo && \ - addgroup -Sg 1000 hugo && \ - adduser -Sg hugo -u 1000 -h /src hugo +# Optionally set HUGO_BUILD_TAGS to "extended" or "nodeploy" when building like so: +# docker build --build-arg HUGO_BUILD_TAGS=extended . +ARG HUGO_BUILD_TAGS -WORKDIR /src +ARG CGO=1 +ENV CGO_ENABLED=${CGO} +ENV GOOS=linux +ENV GO111MODULE=on +WORKDIR /go/src/github.com/gohugoio/hugo + +COPY . /go/src/github.com/gohugoio/hugo/ + +# gcc/g++ are required to build SASS libraries for extended version +RUN apk update && \ + apk add --no-cache gcc g++ musl-dev && \ + go get github.com/magefile/mage + +RUN mage hugo && mage install + +# --- + +FROM alpine:3.12 + +COPY --from=build /go/bin/hugo /usr/bin/hugo + +# libc6-compat & libstdc++ are required for extended SASS libraries +# ca-certificates are required to fetch outside resources (like Twitter oEmbeds) +RUN apk update && \ + apk add --no-cache ca-certificates libc6-compat libstdc++ git + +VOLUME /site +WORKDIR /site + +# Expose port for live server EXPOSE 1313 + +ENTRYPOINT ["hugo"] +CMD ["--help"] \ No newline at end of file