alpine-hugo/Containerfile

41 lines
1.3 KiB
Plaintext
Raw Normal View History

2022-08-31 22:02:12 +02:00
# syntax=docker/dockerfile-upstream:master-labs
FROM docker.io/library/golang:1.18.5-alpine3.16 AS hugobuild
2022-09-01 01:17:08 +02:00
ENV HUGO_VERSION 0.102.2
2022-08-31 22:02:12 +02:00
# this could be so much simpler..
# ref: https://docs.docker.com/engine/reference/builder/#adding-a-git-repository-add-git-ref-dir
# ADD --keep-git-dir=true https://github.com/gohugoio/hugo.git#v${HUGO_VERSION} /hugo
# hadolint ignore=3018
RUN apk add --no-cache git musl-dev gcc g++ && \
git clone https://github.com/gohugoio/hugo.git /hugo
WORKDIR /hugo
RUN git checkout "v${HUGO_VERSION}" && \
\
CGO_ENABLED=1 GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw" \
go build -v -tags extended -ldflags '-s -w -extldflags "-static-pie"' \
&& ./hugo version
FROM docker.io/library/alpine:3.16.2
ARG BUILD_DATE
ARG VCS_REF
LABEL description="Container image with Hugo static site generator (extended version) on Alpine base."
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-url="https://git.dotya.ml/wanderer-containers/alpine-hugo.git" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.license=GPL-3.0-or-later
2022-08-31 22:48:39 +02:00
# required for hugo
# hadolint ignore=3018
RUN apk add --no-cache git
2022-08-31 22:02:12 +02:00
COPY --from=hugobuild /hugo/hugo /usr/bin/hugo
CMD ["/usr/bin/hugo"]
# vim: set ts=4 ft=dockerfile fenc=utf-8 ff=unix :