refactor build code, updated hugo version.

This commit is contained in:
Flea Dope 2021-08-11 19:42:36 -07:00
commit 442afc9b58
4 changed files with 54 additions and 27 deletions

View file

@ -1,10 +1,12 @@
FROM amd64/golang:1.14-alpine AS build
ARG GO_VERSION=1.16.7
RUN apk add --no-cache git build-base && \
git clone --branch v0.70.0 https://github.com/gohugoio/hugo.git && \
cd hugo/ && \
CGO_ENABLED=0 go build -ldflags "-s -w -X github.com/gohugoio/hugo/common/hugo.buildDate=$(date +%Y-%m-%dT%H:%M:%SZ) -X github.com/gohugoio/hugo/common/hugo.commitHash=$(git rev-parse --short HEAD)" -o /tmp/hugo . && \
CGO_ENABLED=1 go build -tags extended -ldflags "-s -w -X github.com/gohugoio/hugo/common/hugo.buildDate=$(date +%Y-%m-%dT%H:%M:%SZ) -X github.com/gohugoio/hugo/common/hugo.commitHash=$(git rev-parse --short HEAD)" -o /tmp/hugo-extended
FROM amd64/golang:$GO_VERSION-alpine AS hugo_builder
ARG HUGO_VERSION=0.87.0
ADD docker/scripts/build_hugo.sh .
RUN sh build_hugo.sh $HUGO_VERSION
FROM plugins/base:linux-amd64
@ -16,10 +18,10 @@ LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
RUN apk --no-cache add git libc6-compat libstdc++
ENV PLUGIN_HUGO_ARCH=64bit
ENV PLUGIN_HUGO_SHIPPED_VERSION=0.70.0
ENV PLUGIN_HUGO_SHIPPED_VERSION=$HUGO_VERSION
COPY --from=build /tmp/hugo /bin/hugo
COPY --from=build /tmp/hugo-extended /bin/hugo-extended
COPY --from=hugo_builder /tmp/hugo /bin/hugo
COPY --from=hugo_builder /tmp/hugo-extended /bin/hugo-extended
ADD release/linux/amd64/drone-hugo /bin/
ENTRYPOINT ["/bin/drone-hugo"]