...
1# syntax=docker/dockerfile:1
2
3ARG GO_VERSION=1.21.8
4ARG ALPINE_VERSION=3.18
5ARG MODOUTDATED_VERSION=v0.8.0
6
7FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
8ENV GOTOOLCHAIN=local
9RUN apk add --no-cache bash git rsync
10WORKDIR /src
11
12FROM base AS vendored
13ENV GOPROXY=https://proxy.golang.org|direct
14RUN --mount=target=/context \
15 --mount=target=.,type=tmpfs \
16 --mount=target=/go/pkg/mod,type=cache <<EOT
17set -e
18rsync -a /context/. .
19./scripts/vendor update
20mkdir /out
21cp -r vendor.mod vendor.sum vendor /out
22EOT
23
24FROM scratch AS update
25COPY --from=vendored /out /out
26
27FROM vendored AS validate
28RUN --mount=target=/context \
29 --mount=target=.,type=tmpfs <<EOT
30set -e
31rsync -a /context/. .
32git add -A
33rm -rf vendor
34cp -rf /out/* .
35./scripts/vendor validate
36EOT
37
38FROM psampaz/go-mod-outdated:${MODOUTDATED_VERSION} AS go-mod-outdated
39FROM base AS outdated
40RUN --mount=target=.,rw \
41 --mount=target=/go/pkg/mod,type=cache \
42 --mount=from=go-mod-outdated,source=/home/go-mod-outdated,target=/usr/bin/go-mod-outdated \
43 ./scripts/vendor outdated
View as plain text