forked from FinVolution/XCoder-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
42 lines (29 loc) · 804 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
41
42
FROM golang:1.20-alpine as builder
ENV GOOS=linux
ENV GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
ENV GOSUMDB=off
ENV TZ=Asia/Shanghai
RUN apk add build-base
WORKDIR /build/xcoder/
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN GOOS=linux CGO_ENABLED=1 GOARCH=amd64 go build -ldflags="-s -w" -installsuffix cgo -o /app/main main.go
FROM alpine
RUN apk add --no-cache --virtual .build-deps \
build-base \
gcc \
tzdata \
wget \
git \
&& apk add --no-cache libstdc++ \
&& apk del .build-deps
WORKDIR /app
COPY --from=builder /app/main /app/main
COPY manifest/config /app/config
EXPOSE 8081
RUN echo $'#!/bin/sh\n\
exec /app/main\n\
' > entrypoint.sh
RUN chmod +x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]