Files
in-server/app/main/api/Dockerfile
2026-03-18 00:55:40 +08:00

56 lines
1.4 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 \
noto-fonts-cjk \
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"]