mirror of
https://github.com/hugomods/docker.git
synced 2025-04-26 05:00:50 +03:00

* feat: add nightly tag * feat: build non-root image for nightly tag * fix: correct nightly build tags
51 lines
1.2 KiB
Text
51 lines
1.2 KiB
Text
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.5.0 AS xx
|
|
|
|
FROM --platform=$BUILDPLATFORM golang:alpine as gobuild
|
|
|
|
RUN apk add clang lld
|
|
|
|
COPY --from=xx / /
|
|
|
|
ARG TARGETPLATFORM
|
|
ARG BUILD_TAGS
|
|
ARG GOPROXY
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
ARG LDFLAGS
|
|
|
|
ENV CGO_ENABLED=1
|
|
|
|
# install build tools.
|
|
RUN xx-apk add --no-cache gcc g++ musl-dev git
|
|
|
|
WORKDIR /src
|
|
|
|
# download modules.
|
|
COPY src/go.mod src/go.sum .
|
|
RUN --mount=type=cache,target=/go/pkg \
|
|
go mod download
|
|
|
|
# build Hugo.
|
|
COPY src .
|
|
RUN --mount=type=cache,target=/go/pkg \
|
|
--mount=type=cache,target=/root/.cache/go-build,id=go-pkg-$TARGETPLATFORM \
|
|
if [[ -z "$BUILD_TAGS" ]]; \
|
|
then \
|
|
xx-go build -ldflags="$LDFLAGS" -o /usr/bin/hugo; \
|
|
else \
|
|
xx-go build -ldflags="$LDFLAGS" -tags $BUILD_TAGS -o /usr/bin/hugo; \
|
|
fi
|
|
|
|
FROM alpine as dart-sass
|
|
|
|
ARG TARGETARCH
|
|
|
|
RUN apk add jq curl
|
|
RUN curl -s https://api.github.com/repos/sass/dart-sass/releases/latest | \
|
|
jq -r --arg REGEXP "^.+-linux-${TARGETARCH/amd64/x64}-musl.tar.gz$" '.assets[].browser_download_url | match($REGEXP) | .string' | \
|
|
xargs -n1 curl -L -o dart-sass.tar.gz
|
|
RUN tar -C /opt -xzf dart-sass.tar.gz
|
|
|
|
FROM golang:alpine as builder
|
|
|
|
COPY --from=gobuild /usr/bin/hugo /usr/bin/hugo
|