Browse Source

go add dockerfile

liuyuqi-dellpc 2 years ago
parent
commit
85e9102721
1 changed files with 21 additions and 0 deletions
  1. 21 0
      go/Dockerfile

+ 21 - 0
go/Dockerfile

@@ -0,0 +1,21 @@
+FROM golang:alpine as builder
+WORKDIR /workspaces
+COPY . /workspaces/
+ENV GOPROXY=https://goproxy.cn,direct
+RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -s" main.go
+
+FROM alpine as runner
+WORKDIR /workspaces
+COPY --from=builder /workspaces/main .
+COPY --from=builder /workspaces/config ./config
+
+RUN echo "https://mirrors.aliyun.com/alpine/v3.8/main/" > /etc/apk/repositories \
+    && echo "https://mirrors.aliyun.com/alpine/v3.8/community/" >> /etc/apk/repositories \
+    && apk add --no-cache tzdata \
+    && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime  \
+    && echo Asia/Shanghai > /etc/timezone \
+    && apk del tzdata
+
+EXPOSE 8888
+VOLUME ["/workspaces/config","/workspaces/log"]
+ENTRYPOINT ["./main"]