-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
32 lines (27 loc) · 1.05 KB
/
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
29
30
31
32
# Build the manager binary
FROM golang:1.18.7-alpine3.15 as builder
WORKDIR /app
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# 坑:
# 报错 go mod download: google.golang.org/[email protected]: read tcp 172.17.0.3:60862->14.204.51.154:443: read: connection reset by peer
# The command '/bin/sh -c go mod download' returned a non-zero code: 1
# make: *** [docker-build] 错误 1
ENV GOPROXY=https://goproxy.cn,direct
ENV GO111MODULE=on
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Copy the go source
# # 需要把该放入的都copy进去,如果报出 package xxxxx is not in GOROOT => 就是这个问题。
COPY main.go main.go
COPY pkg/ pkg/
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o mypoddeployeroperator main.go
FROM alpine:3.12
WORKDIR /app
# 需要的文件需要复制过来
COPY --from=builder /app/mypoddeployeroperator .
USER 65532:65532
ENTRYPOINT ["./mypoddeployeroperator"]