first commit
This commit is contained in:
54
app/main/api/Dockerfile
Normal file
54
app/main/api/Dockerfile
Normal file
@@ -0,0 +1,54 @@
|
||||
FROM golang:1.23.4-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 app/main/api/etc /app/etc
|
||||
COPY app/main/api/static /app/static
|
||||
RUN go build -ldflags="-s -w" -o /app/main app/main/api/main.go
|
||||
|
||||
|
||||
FROM alpine:3.19
|
||||
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||
&& apk update --no-cache \
|
||||
# 基础运行环境
|
||||
&& apk add --no-cache ca-certificates tzdata \
|
||||
# chromedp 所需的 Chromium 浏览器及依赖
|
||||
&& apk add --no-cache \
|
||||
chromium \
|
||||
nss \
|
||||
freetype \
|
||||
ttf-freefont \
|
||||
harfbuzz \
|
||||
font-noto-emoji \
|
||||
dumb-init \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
# 为 chromedp 指定默认的 Chrome 路径(Alpine 下 chromium 包的可执行文件)
|
||||
ENV CHROME_BIN=/usr/bin/chromium-browser
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/main /app/main
|
||||
COPY --from=builder /app/etc /app/etc
|
||||
COPY --from=builder /app/static /app/static
|
||||
|
||||
# 报告 PDF 缓存目录(与配置中的 ./data/report-pdf 对应)
|
||||
RUN mkdir -p /app/data/report-pdf
|
||||
VOLUME ["/app/data/report-pdf"]
|
||||
|
||||
ENTRYPOINT ["dumb-init", "--"]
|
||||
CMD ["./main", "-f", "etc/main.yaml"]
|
||||
Reference in New Issue
Block a user