-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
42 lines (31 loc) · 1.24 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
33
34
35
36
37
38
39
40
41
42
FROM golang:alpine as builder
LABEL maintainer="Hetao<hetao@hetao.name>"
LABEL version="1.0"
WORKDIR /data/scws/
ENV GOPROXY=https://goproxy.cn,direct
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
&& apk update \
&& apk add tzdata \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
&& apk add tree build-base git
COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go build -v -ldflags "-X main.version=1.0.0 -X main.build=`date -u +%Y-%m-%d%H:%M:%S`" -o bin/scws
FROM alpine as prod
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
&& apk update \
&& apk add tzdata \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
&& apk add ca-certificates
WORKDIR /data/scws/
RUN mkdir bin/
RUN mkdir -p etc/dict/
COPY etc/config.json /data/scws/etc/
COPY etc/dict/* /data/scws/etc/dict/
COPY --from=0 /data/scws/bin/scws bin/
HEALTHCHECK --interval=5s --timeout=5s --retries=3 \
CMD ps aux | grep "scws" | grep -v "grep" > /dev/null; if [ 0 != $? ]; then exit 1; fi
CMD ["/data/scws/bin/scws", "-b" , "0.0.0.0:80"]