forked from go-swagger/go-swagger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
28 lines (18 loc) · 969 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
FROM --platform=$BUILDPLATFORM golang:alpine as cross
ARG TARGETOS TARGETARCH
ARG commit_hash="dev"
ARG tag_name="dev"
ADD . /work
WORKDIR /work
RUN apk --no-cache add ca-certificates shared-mime-info mailcap git build-base binutils-gold
RUN mkdir -p bin &&\
LDFLAGS="$LDFLAGS -X github.com/go-swagger/go-swagger/cmd/swagger/commands.Commit=${commit_hash}" &&\
LDFLAGS="$LDFLAGS -X github.com/go-swagger/go-swagger/cmd/swagger/commands.Version=${tag_name}" &&\
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -tags osusergo,netgo -o bin/swagger -ldflags "$LDFLAGS" -a ./cmd/swagger
FROM --platform=$TARGETPLATFORM golang:alpine
LABEL maintainer="Ivan Porto Carrero <[email protected]> (@casualjim)"
RUN apk --no-cache add ca-certificates shared-mime-info mailcap git build-base
COPY --from=cross /work/bin/swagger /usr/bin/swagger
COPY --from=cross /work/generator/templates/contrib /templates/
ENTRYPOINT ["/usr/bin/swagger"]
CMD ["--help"]