add args for dockerfile & update go/hugo versions

- Replaced hard-coded golang version and hugo version with GO_VERSION
    and HUGO_VERSION args.
  - Update builtin HUGO_VERSION from 0.70.0 to 0.101.0.
  - Update GO_VERSION from 1.14 to 1.18.3.

replace libstdc++ source from v3.15 to edge

  hugo-extended compiled by go1.18.3 needs libstdc++ v11.2.1 provided by
  the alpine edge repo.
  - Changed repository of apk add command in dockerfiles.
This commit is contained in:
AzurCrystal 2022-08-03 00:27:40 +08:00
parent 748a401cec
commit e16f04fcf3
3 changed files with 24 additions and 12 deletions

View File

@ -1,7 +1,11 @@
FROM amd64/golang:1.14-alpine AS build ARG GO_VERSION=1.18.3
FROM amd64/golang:$GO_VERSION-alpine AS build
ARG HUGO_VERSION=0.101.0
RUN apk add --no-cache git build-base && \ RUN apk add --no-cache git build-base && \
git clone --branch v0.70.0 https://github.com/gohugoio/hugo.git && \ git clone --branch v$HUGO_VERSION https://github.com/gohugoio/hugo.git && \
cd hugo/ && \ 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=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 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
@ -13,10 +17,10 @@ LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
org.label-schema.vendor="Drone.IO Community" \ org.label-schema.vendor="Drone.IO Community" \
org.label-schema.schema-version="1.0" org.label-schema.schema-version="1.0"
RUN apk --no-cache add git libc6-compat libstdc++ RUN apk --no-cache --repository http://nl.alpinelinux.org/alpine/edge/main add git libc6-compat libstdc++
ENV PLUGIN_HUGO_ARCH=64bit ENV PLUGIN_HUGO_ARCH=64bit
ENV PLUGIN_HUGO_SHIPPED_VERSION=0.70.0 ENV PLUGIN_HUGO_SHIPPED_VERSION=0.101.0
COPY --from=build /tmp/hugo /bin/hugo COPY --from=build /tmp/hugo /bin/hugo
COPY --from=build /tmp/hugo-extended /bin/hugo-extended COPY --from=build /tmp/hugo-extended /bin/hugo-extended

View File

@ -1,7 +1,11 @@
FROM arm32v6/golang:1.14-alpine AS build ARG GO_VERSION=1.18.3
FROM arm32v6/golang:$GO_VERSION-alpine AS build
ARG HUGO_VERSION=0.101.0
RUN apk add --no-cache git build-base && \ RUN apk add --no-cache git build-base && \
git clone --branch v0.70.0 https://github.com/gohugoio/hugo.git && \ git clone --branch v$HUGO_VERSION https://github.com/gohugoio/hugo.git && \
cd hugo/ && \ 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=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 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
@ -13,10 +17,10 @@ LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
org.label-schema.vendor="Drone.IO Community" \ org.label-schema.vendor="Drone.IO Community" \
org.label-schema.schema-version="1.0" org.label-schema.schema-version="1.0"
RUN apk --no-cache add git libc6-compat libstdc++ RUN apk --no-cache --repository http://nl.alpinelinux.org/alpine/edge/main add git libc6-compat libstdc++
ENV PLUGIN_HUGO_ARCH=arm ENV PLUGIN_HUGO_ARCH=arm
ENV PLUGIN_HUGO_SHIPPED_VERSION=0.70.0 ENV PLUGIN_HUGO_SHIPPED_VERSION=0.101.0
COPY --from=build /tmp/hugo /bin/hugo COPY --from=build /tmp/hugo /bin/hugo
COPY --from=build /tmp/hugo-extended /bin/hugo-extended COPY --from=build /tmp/hugo-extended /bin/hugo-extended

View File

@ -1,7 +1,11 @@
FROM arm64v8/golang:1.14-alpine AS build ARG GO_VERSION=1.18.3
FROM arm64v8/golang:$GO_VERSION-alpine AS build
ARG HUGO_VERSION=0.101.0
RUN apk add --no-cache git build-base && \ RUN apk add --no-cache git build-base && \
git clone --branch v0.70.0 https://github.com/gohugoio/hugo.git && \ git clone --branch v$HUGO_VERSION https://github.com/gohugoio/hugo.git && \
cd hugo/ && \ 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=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 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
@ -13,10 +17,10 @@ LABEL maintainer="Drone.IO Community <drone-dev@googlegroups.com>" \
org.label-schema.vendor="Drone.IO Community" \ org.label-schema.vendor="Drone.IO Community" \
org.label-schema.schema-version="1.0" org.label-schema.schema-version="1.0"
RUN apk --no-cache add git libc6-compat libstdc++ RUN apk --no-cache --repository http://nl.alpinelinux.org/alpine/edge/main add git libc6-compat libstdc++
ENV PLUGIN_HUGO_ARCH=arm64 ENV PLUGIN_HUGO_ARCH=arm64
ENV PLUGIN_HUGO_SHIPPED_VERSION=0.70.0 ENV PLUGIN_HUGO_SHIPPED_VERSION=0.101.0
COPY --from=build /tmp/hugo /bin/hugo COPY --from=build /tmp/hugo /bin/hugo
COPY --from=build /tmp/hugo-extended /bin/hugo-extended COPY --from=build /tmp/hugo-extended /bin/hugo-extended