Dockerfile: swagger cross build with TARGETPLATFORM
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
879b023706
commit
ed95e1a9ff
1 changed files with 19 additions and 13 deletions
32
Dockerfile
32
Dockerfile
|
@ -83,22 +83,28 @@ RUN --mount=from=registry-src,src=/usr/src/registry,rw \
|
||||||
esac
|
esac
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
FROM base AS swagger
|
# go-swagger
|
||||||
WORKDIR $GOPATH/src/github.com/go-swagger/go-swagger
|
FROM base AS swagger-src
|
||||||
|
WORKDIR /usr/src/swagger
|
||||||
|
# Currently uses a fork from https://github.com/kolyshkin/go-swagger/tree/golang-1.13-fix
|
||||||
|
# TODO: move to under moby/ or fix upstream go-swagger to work for us.
|
||||||
|
RUN git init . && git remote add origin "https://github.com/kolyshkin/go-swagger.git"
|
||||||
# GO_SWAGGER_COMMIT specifies the version of the go-swagger binary to build and
|
# GO_SWAGGER_COMMIT specifies the version of the go-swagger binary to build and
|
||||||
# install. Go-swagger is used in CI for validating swagger.yaml in hack/validate/swagger-gen
|
# install. Go-swagger is used in CI for validating swagger.yaml in hack/validate/swagger-gen
|
||||||
#
|
ARG GO_SWAGGER_COMMIT=c56166c036004ba7a3a321e5951ba472b9ae298c
|
||||||
# Currently uses a fork from https://github.com/kolyshkin/go-swagger/tree/golang-1.13-fix,
|
RUN git fetch -q --depth 1 origin "${GO_SWAGGER_COMMIT}" && git checkout -q FETCH_HEAD
|
||||||
# TODO: move to under moby/ or fix upstream go-swagger to work for us.
|
|
||||||
ENV GO_SWAGGER_COMMIT c56166c036004ba7a3a321e5951ba472b9ae298c
|
FROM base AS swagger
|
||||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
WORKDIR /go/src/github.com/go-swagger/go-swagger
|
||||||
|
ARG TARGETPLATFORM
|
||||||
|
RUN --mount=from=swagger-src,src=/usr/src/swagger,rw \
|
||||||
|
--mount=type=cache,target=/root/.cache/go-build,id=swagger-build-$TARGETPLATFORM \
|
||||||
--mount=type=cache,target=/go/pkg/mod \
|
--mount=type=cache,target=/go/pkg/mod \
|
||||||
--mount=type=tmpfs,target=/go/src/ \
|
--mount=type=tmpfs,target=/go/src/ <<EOT
|
||||||
set -x \
|
set -e
|
||||||
&& git clone https://github.com/kolyshkin/go-swagger.git . \
|
xx-go build -o /build/swagger ./cmd/swagger
|
||||||
&& git checkout -q "$GO_SWAGGER_COMMIT" \
|
xx-verify /build/swagger
|
||||||
&& go build -o /build/swagger github.com/go-swagger/go-swagger/cmd/swagger
|
EOT
|
||||||
|
|
||||||
# frozen-images
|
# frozen-images
|
||||||
# See also frozenImages in "testutil/environment/protect.go" (which needs to
|
# See also frozenImages in "testutil/environment/protect.go" (which needs to
|
||||||
|
|
Loading…
Reference in a new issue