Skip to content

Commit ee3ae0d

Browse files
authored
dockerfile优化:减小镜像大小
dockerfile优化:减小镜像大小,RUN合并为一条命令
1 parent f99c782 commit ee3ae0d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

server/Dockerfile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@ FROM golang:alpine as builder
33
WORKDIR /go/src/github.com/flipped-aurora/gin-vue-admin/server
44
COPY . .
55

6-
RUN go env -w GO111MODULE=on
7-
RUN go env -w GOPROXY=https://goproxy.cn,direct
8-
RUN go env -w CGO_ENABLED=0
9-
RUN go env
10-
RUN go mod tidy
11-
RUN go build -o server .
6+
RUN go env -w GO111MODULE=on \
7+
&& go env -w GOPROXY=https://goproxy.cn,direct \
8+
&& go env -w CGO_ENABLED=0 \
9+
&& go env \
10+
&& go mod tidy \
11+
&& go build -o server .
1212

1313
FROM alpine:latest
14+
1415
LABEL MAINTAINER="SliverHorn@[email protected]"
1516

1617
WORKDIR /go/src/github.com/flipped-aurora/gin-vue-admin/server
1718

18-
COPY --from=0 /go/src/github.com/flipped-aurora/gin-vue-admin/server ./
19+
COPY --from=0 /go/src/github.com/flipped-aurora/gin-vue-admin/server/server ./
20+
COPY --from=0 /go/src/github.com/flipped-aurora/gin-vue-admin/server/resource ./resource/
21+
COPY --from=0 /go/src/github.com/flipped-aurora/gin-vue-admin/server/config.docker.yaml ./
1922

2023
EXPOSE 8888
21-
2224
ENTRYPOINT ./server -c config.docker.yaml

0 commit comments

Comments
 (0)