2020-07-03 15:08:57 +00:00
|
|
|
FROM golang:1 as builder
|
2020-07-03 12:03:06 +00:00
|
|
|
|
2020-07-03 15:08:57 +00:00
|
|
|
WORKDIR /src
|
2020-07-03 12:03:06 +00:00
|
|
|
|
2020-07-14 11:33:52 +00:00
|
|
|
RUN set -x \
|
|
|
|
&& apt update \
|
|
|
|
&& apt install -y upx-ucl
|
|
|
|
|
|
|
|
COPY . /src
|
|
|
|
|
2020-07-03 15:08:57 +00:00
|
|
|
ARG VERSION=dev
|
2020-07-03 12:03:06 +00:00
|
|
|
|
2020-07-03 15:08:57 +00:00
|
|
|
# https://github.com/golang/go/wiki/Modules#how-do-i-use-vendoring-with-modules-is-vendoring-going-away
|
|
|
|
# go build -mod=vendor
|
|
|
|
# The -gcflags "all=-N -l" flag helps us get a better debug experience
|
|
|
|
RUN set -x \
|
|
|
|
&& export BUILD=$(date -u +%s%N) \
|
|
|
|
&& export REPO=$(go list -m) \
|
|
|
|
&& export LDFLAGS="-X ${REPO}/misc.Version=${VERSION} -X ${REPO}/misc.Build=${BUILD}" \
|
|
|
|
&& export GOGC=off \
|
|
|
|
&& export CGO_ENABLED=0 \
|
|
|
|
&& [ -d "./vendor" ] || go mod vendor \
|
2020-12-01 07:02:26 +00:00
|
|
|
&& go build \
|
|
|
|
-v \
|
|
|
|
-mod=vendor \
|
|
|
|
-trimpath \
|
2020-12-02 09:46:51 +00:00
|
|
|
-ldflags "${LDFLAGS}" \
|
2020-12-01 07:02:26 +00:00
|
|
|
-o /go/bin/neofs-s3 ./cmd/gate \
|
2020-07-14 11:33:52 +00:00
|
|
|
&& upx -3 /go/bin/neofs-s3
|
2020-07-03 12:03:06 +00:00
|
|
|
|
2020-07-03 15:08:57 +00:00
|
|
|
# Executable image
|
2020-07-14 11:33:52 +00:00
|
|
|
FROM scratch
|
2020-07-03 12:03:06 +00:00
|
|
|
|
2020-07-03 15:08:57 +00:00
|
|
|
WORKDIR /
|
2020-07-03 12:03:06 +00:00
|
|
|
|
2020-12-01 07:56:02 +00:00
|
|
|
COPY --from=builder /go/bin/neofs-s3 /bin/neofs-s3
|
2020-07-03 15:08:57 +00:00
|
|
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
2020-07-03 12:03:06 +00:00
|
|
|
|
2020-12-01 07:56:02 +00:00
|
|
|
ENTRYPOINT ["/bin/neofs-s3"]
|