-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
28 lines (22 loc) · 865 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 golang:1.12-alpine as builder
ARG UPX_VERSION=3.95
WORKDIR /app
# Cache the fetched Go packages
RUN apk add --no-cache gcc git musl-dev
COPY ./go.mod ./go.sum ./
RUN go mod download
# Then build the binary
COPY ./ ./
RUN set -euo pipefail && \
go build -v -ldflags "-linkmode external -extldflags -static -s -w"; \
wget https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-amd64_linux.tar.xz; \
tar xvf upx-${UPX_VERSION}-amd64_linux.tar.xz; \
mv upx-${UPX_VERSION}-amd64_linux/upx /usr/local/bin/; \
rm -r upx-${UPX_VERSION}-amd64_linux upx-${UPX_VERSION}-amd64_linux.tar.xz; \
upx --best nomad-parametric-autoscaler; \
:
FROM alpine:3.9 as release
WORKDIR /app
RUN apk add --no-cache ca-certificates
COPY --from=builder /app/nomad-parametric-autoscaler ./
CMD ["/app/nomad-parametric-autoscaler"]