-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
DockerfileCN
47 lines (35 loc) · 1.38 KB
/
DockerfileCN
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
43
44
45
46
47
FROM node:12.18.3-alpine3.12 as frontend-builder
WORKDIR /app
COPY frontend /app
#RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.12/main" > /etc/apk/repositories \
# && apk add git
RUN yarn config set registry https://registry.npm.taobao.org && yarn install
RUN yarn build
FROM golang:1.16.4-alpine as backend-builder
RUN go env -w GOPROXY=https://goproxy.cn
RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.12/main" > /etc/apk/repositories
RUN apk add build-base git musl-dev
COPY models /src/godnslog/models
COPY server /src/godnslog/server
COPY cache /src/godnslog/cache
COPY *.go go.mod /src/godnslog/
WORKDIR /src/godnslog
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -mod=mod -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/godnslog
FROM alpine:3.13.5
# tinghua mirror
RUN echo "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.13/main" > /etc/apk/repositories
RUN apk add --no-cache -U tzdata ca-certificates libcap && \
update-ca-certificates
RUN mkdir -p /app
COPY --from=backend-builder /go/bin/godnslog /app/godnslog
COPY --from=frontend-builder /app/dist /app/dist
ARG UID=1000
ARG GID=1000
RUN addgroup -g $GID -S app && adduser -u $UID -S -g app app && \
chown -R app:app /app && \
setcap cap_net_bind_service=eip /app/godnslog
WORKDIR /app
USER app
EXPOSE 8080
EXPOSE 53/UDP 53/TCP
ENTRYPOINT [ "/app/godnslog" ]