-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
40 lines (27 loc) · 886 Bytes
/
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
33
34
35
36
37
38
39
40
FROM golang:alpine AS builder
LABEL stage=gobuilder
ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn,direct
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk update --no-cache && apk add --no-cache tzdata
WORKDIR /build
ADD go.mod .
ADD go.sum .
RUN go mod download
COPY . .
COPY ./service/hs/api/etc /app/etc
RUN go build -ldflags="-s -w" -o /app/hs service/hs/api/hs.go
#运行时环境
#不允许进入容器 用scratch
#FROM scratch
#允许进入容器
FROM alpine
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
ENV TZ Asia/Shanghai
WORKDIR /app
COPY --from=builder /app/hs /app/hs
COPY --from=builder /app/etc /app/etc
# 声明服务端口
EXPOSE 8881
CMD ["./hs", "-f", "etc/hs_docker_test.yaml"]