1
|
-FROM golang:latest
|
1
|
+#FROM golang:latest
|
|
|
2
|
+#MAINTAINER 陈志颖 <steve.d.chan@qq.com>
|
|
|
3
|
+#ENV APP_DIR $GOPATH/src/allied-creation-cooperation
|
|
|
4
|
+#RUN mkdir -p $APP_DIR
|
|
|
5
|
+#WORKDIR $APP_DIR/
|
|
|
6
|
+#COPY ./pkg pkg
|
|
|
7
|
+#COPY ./config config
|
|
|
8
|
+#COPY ./go.mod go.mod
|
|
|
9
|
+#COPY ./go.sum go.sum
|
|
|
10
|
+#COPY ./main.go main.go
|
|
|
11
|
+#RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
|
|
|
12
|
+#ENV GO111MODULE on
|
|
|
13
|
+#ENV GOPROXY https://goproxy.io
|
|
|
14
|
+#RUN ["go","mod","tidy"]
|
|
|
15
|
+#RUN ["ls"]
|
|
|
16
|
+#RUN ["go","build"]
|
|
|
17
|
+#ENTRYPOINT ["./allied-creation-cooperation"]
|
|
|
18
|
+
|
|
|
19
|
+#############################
|
|
|
20
|
+## STEP 1 build executable binary
|
|
|
21
|
+#############################
|
|
|
22
|
+FROM golang:latest AS builder
|
2
|
MAINTAINER 陈志颖 <steve.d.chan@qq.com>
|
23
|
MAINTAINER 陈志颖 <steve.d.chan@qq.com>
|
3
|
-ENV APP_DIR $GOPATH/src/allied-creation-cooperation
|
|
|
4
|
-RUN mkdir -p $APP_DIR
|
|
|
5
|
-WORKDIR $APP_DIR/
|
|
|
6
|
-COPY ./pkg pkg
|
|
|
7
|
-COPY ./config config
|
|
|
8
|
-COPY ./go.mod go.mod
|
|
|
9
|
-COPY ./go.sum go.sum
|
|
|
10
|
-COPY ./main.go main.go
|
24
|
+RUN mkdir /app
|
|
|
25
|
+WORKDIR /app
|
|
|
26
|
+COPY . /app
|
11
|
RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
|
27
|
RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
|
12
|
-ENV GO111MODULE on
|
|
|
13
|
-ENV GOPROXY https://goproxy.io
|
|
|
14
|
-RUN ["go","mod","tidy"]
|
|
|
15
|
-RUN ["ls"]
|
|
|
16
|
-RUN ["go","build"]
|
|
|
17
|
-ENTRYPOINT ["./allied-creation-cooperation"] |
|
|
|
|
28
|
+RUN GO111MODULE="on" GOPROXY="https://goproxy.cn" CGO_ENABLED=0 GOOS=linux go build -o allied-creation-cooperation
|
|
|
29
|
+
|
|
|
30
|
+#############################
|
|
|
31
|
+## STEP 2 build a small image
|
|
|
32
|
+############################
|
|
|
33
|
+FROM scratch as final
|
|
|
34
|
+COPY --from=builder /app/allied-creation-cooperation /app/allied-creation-cooperation
|
|
|
35
|
+ENTRYPOINT ["./app/allied-creation-cooperation"] |