forked from TrueCloudLab/distribution
dockerfiles: formatting
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
b066451b40
commit
0e17e54091
4 changed files with 42 additions and 42 deletions
24
Dockerfile
24
Dockerfile
|
@ -24,11 +24,11 @@ ARG TARGETPLATFORM
|
||||||
ARG LDFLAGS="-s -w"
|
ARG LDFLAGS="-s -w"
|
||||||
ARG BUILDTAGS="include_oss include_gcs"
|
ARG BUILDTAGS="include_oss include_gcs"
|
||||||
RUN --mount=type=bind,target=/src,rw \
|
RUN --mount=type=bind,target=/src,rw \
|
||||||
--mount=type=cache,target=/root/.cache/go-build \
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
--mount=target=/go/pkg/mod,type=cache \
|
--mount=target=/go/pkg/mod,type=cache \
|
||||||
--mount=type=bind,source=/tmp/.ldflags,target=/tmp/.ldflags,from=version \
|
--mount=type=bind,source=/tmp/.ldflags,target=/tmp/.ldflags,from=version \
|
||||||
set -x ; xx-go build -trimpath -ldflags "$(cat /tmp/.ldflags) ${LDFLAGS}" -o /usr/bin/registry ./cmd/registry \
|
set -x ; xx-go build -trimpath -ldflags "$(cat /tmp/.ldflags) ${LDFLAGS}" -o /usr/bin/registry ./cmd/registry \
|
||||||
&& xx-verify --static /usr/bin/registry
|
&& xx-verify --static /usr/bin/registry
|
||||||
|
|
||||||
FROM scratch AS binary
|
FROM scratch AS binary
|
||||||
COPY --from=build /usr/bin/registry /
|
COPY --from=build /usr/bin/registry /
|
||||||
|
@ -39,13 +39,13 @@ ARG TARGETARCH
|
||||||
ARG TARGETVARIANT
|
ARG TARGETVARIANT
|
||||||
WORKDIR /work
|
WORKDIR /work
|
||||||
RUN --mount=from=binary,target=/build \
|
RUN --mount=from=binary,target=/build \
|
||||||
--mount=type=bind,target=/src \
|
--mount=type=bind,target=/src \
|
||||||
--mount=type=bind,source=/tmp/.version,target=/tmp/.version,from=version \
|
--mount=type=bind,source=/tmp/.version,target=/tmp/.version,from=version \
|
||||||
VERSION=$(cat /tmp/.version) \
|
VERSION=$(cat /tmp/.version) \
|
||||||
&& mkdir -p /out \
|
&& mkdir -p /out \
|
||||||
&& cp /build/registry /src/README.md /src/LICENSE . \
|
&& cp /build/registry /src/README.md /src/LICENSE . \
|
||||||
&& tar -czvf "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.tgz" * \
|
&& tar -czvf "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.tgz" * \
|
||||||
&& sha256sum -z "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.tgz" | awk '{ print $1 }' > "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.tgz.sha256"
|
&& sha256sum -z "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.tgz" | awk '{ print $1 }' > "/out/registry_${VERSION#v}_${TARGETOS}_${TARGETARCH}${TARGETVARIANT}.tar.tgz.sha256"
|
||||||
|
|
||||||
FROM scratch AS artifact
|
FROM scratch AS artifact
|
||||||
COPY --from=releaser /out /
|
COPY --from=releaser /out /
|
||||||
|
|
|
@ -9,8 +9,8 @@ RUN apk add --no-cache git gpg
|
||||||
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS gitvalidation
|
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS gitvalidation
|
||||||
ARG GIT_VALIDATION_VERSION=v1.1.0
|
ARG GIT_VALIDATION_VERSION=v1.1.0
|
||||||
RUN --mount=type=cache,target=/root/.cache \
|
RUN --mount=type=cache,target=/root/.cache \
|
||||||
--mount=type=cache,target=/go/pkg/mod \
|
--mount=type=cache,target=/go/pkg/mod \
|
||||||
GOBIN=/out go install "github.com/vbatts/git-validation@${GIT_VALIDATION_VERSION}"
|
GOBIN=/out go install "github.com/vbatts/git-validation@${GIT_VALIDATION_VERSION}"
|
||||||
|
|
||||||
FROM base AS validate
|
FROM base AS validate
|
||||||
ARG COMMIT_RANGE
|
ARG COMMIT_RANGE
|
||||||
|
@ -18,6 +18,6 @@ RUN if [ -z "$COMMIT_RANGE" ]; then echo "COMMIT_RANGE required" && exit 1; fi
|
||||||
ENV GIT_CHECK_EXCLUDE="./vendor"
|
ENV GIT_CHECK_EXCLUDE="./vendor"
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
RUN --mount=type=bind,target=. \
|
RUN --mount=type=bind,target=. \
|
||||||
--mount=type=cache,target=/root/.cache \
|
--mount=type=cache,target=/root/.cache \
|
||||||
--mount=from=gitvalidation,source=/out/git-validation,target=/usr/bin/git-validation \
|
--mount=from=gitvalidation,source=/out/git-validation,target=/usr/bin/git-validation \
|
||||||
git-validation -q -range "$COMMIT_RANGE" -run short-subject,dangling-whitespace
|
git-validation -q -range "${COMMIT_RANGE}" -run short-subject,dangling-whitespace
|
||||||
|
|
|
@ -13,6 +13,6 @@ WORKDIR /src
|
||||||
FROM base
|
FROM base
|
||||||
ENV GOFLAGS="-buildvcs=false"
|
ENV GOFLAGS="-buildvcs=false"
|
||||||
RUN --mount=type=bind,target=. \
|
RUN --mount=type=bind,target=. \
|
||||||
--mount=type=cache,target=/root/.cache \
|
--mount=type=cache,target=/root/.cache \
|
||||||
--mount=from=golangci-lint,source=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \
|
--mount=from=golangci-lint,source=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \
|
||||||
golangci-lint run
|
golangci-lint run
|
||||||
|
|
|
@ -10,14 +10,14 @@ WORKDIR /src
|
||||||
|
|
||||||
FROM base AS vendored
|
FROM base AS vendored
|
||||||
RUN --mount=target=/context \
|
RUN --mount=target=/context \
|
||||||
--mount=target=.,type=tmpfs \
|
--mount=target=.,type=tmpfs \
|
||||||
--mount=target=/go/pkg/mod,type=cache <<EOT
|
--mount=target=/go/pkg/mod,type=cache <<EOT
|
||||||
set -e
|
set -e
|
||||||
rsync -a /context/. .
|
rsync -a /context/. .
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go mod vendor
|
go mod vendor
|
||||||
mkdir /out
|
mkdir /out
|
||||||
cp -r go.mod go.sum vendor /out
|
cp -r go.mod go.sum vendor /out
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
FROM scratch AS update
|
FROM scratch AS update
|
||||||
|
@ -25,23 +25,23 @@ COPY --from=vendored /out /out
|
||||||
|
|
||||||
FROM vendored AS validate
|
FROM vendored AS validate
|
||||||
RUN --mount=target=/context \
|
RUN --mount=target=/context \
|
||||||
--mount=target=.,type=tmpfs <<EOT
|
--mount=target=.,type=tmpfs <<EOT
|
||||||
set -e
|
set -e
|
||||||
rsync -a /context/. .
|
rsync -a /context/. .
|
||||||
git add -A
|
git add -A
|
||||||
rm -rf vendor
|
rm -rf vendor
|
||||||
cp -rf /out/* .
|
cp -rf /out/* .
|
||||||
if [ -n "$(git status --porcelain -- go.mod go.sum vendor)" ]; then
|
if [ -n "$(git status --porcelain -- go.mod go.sum vendor)" ]; then
|
||||||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make vendor"'
|
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make vendor"'
|
||||||
git status --porcelain -- go.mod go.sum vendor
|
git status --porcelain -- go.mod go.sum vendor
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
FROM psampaz/go-mod-outdated:${MODOUTDATED_VERSION} AS go-mod-outdated
|
FROM psampaz/go-mod-outdated:${MODOUTDATED_VERSION} AS go-mod-outdated
|
||||||
FROM base AS outdated
|
FROM base AS outdated
|
||||||
ARG _RANDOM
|
ARG _RANDOM
|
||||||
RUN --mount=target=.,ro \
|
RUN --mount=target=.,ro \
|
||||||
--mount=target=/go/pkg/mod,type=cache \
|
--mount=target=/go/pkg/mod,type=cache \
|
||||||
--mount=from=go-mod-outdated,source=/home/go-mod-outdated,target=/usr/bin/go-mod-outdated \
|
--mount=from=go-mod-outdated,source=/home/go-mod-outdated,target=/usr/bin/go-mod-outdated \
|
||||||
go list -mod=readonly -u -m -json all | go-mod-outdated -update -direct
|
go list -mod=readonly -u -m -json all | go-mod-outdated -update -direct
|
||||||
|
|
Loading…
Reference in a new issue