optimize Dockerfile for size
This commit is contained in:
parent
05588986c0
commit
0eb06dcf9a
3 changed files with 4 additions and 4 deletions
|
@ -1,16 +1,16 @@
|
||||||
FROM golang:1.14 AS builder
|
FROM golang:1.14 AS builder
|
||||||
COPY . /app
|
COPY . /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
ARG GOARCH=amd64
|
||||||
RUN go generate
|
RUN go generate
|
||||||
RUN \
|
RUN \
|
||||||
CGO_ENABLED=0 \
|
CGO_ENABLED=0 \
|
||||||
GOOS=linux \
|
GOOS=linux \
|
||||||
GOPROXY=https://proxy.golang.org,direct \
|
GOPROXY=https://proxy.golang.org,direct \
|
||||||
go build -o main main.go
|
go build -ldflags "-s -w" -o main .
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
COPY contrib/etc_group /etc/group
|
COPY contrib/etc/group contrib/etc/passwd /etc/
|
||||||
COPY contrib/etc_passwd /etc/passwd
|
|
||||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||||
COPY --from=builder /app/main /main
|
COPY --from=builder /app/main /main
|
||||||
USER user
|
USER user
|
||||||
|
|
Loading…
Reference in a new issue