Files
kami_backend/manifest/docker/Dockerfile
danial a7ecd1147b fix(docker): 优化Alpine镜像源配置及时区设置
- 移除阿里云镜像源配置,改用默认镜像源进行apk更新
- 保持时区数据安装和上海时区设置不变
- 简化Dockerfile相关命令,提升构建效率
2025-12-07 00:48:37 +08:00

38 lines
977 B
Go
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.25-alpine AS builder
ARG USE_PROXY
WORKDIR /build
COPY ./ /build/
# 根据USE_PROXY参数设置环境变量
RUN export GO111MODULE=on GOOS=linux GOARCH=amd64 && \
go mod tidy && go build -ldflags "-s -w" -o main main.go
FROM alpine:latest
WORKDIR /app
ENV TZ=Asia/Shanghai
# 定义参数
ARG USE_PROXY
ENV serverName="测试"
COPY --from=builder /build/main /app/
COPY --from=builder /build/resource/public/ /app/resource/public/
COPY --from=builder /build/manifest/config/ /app/manifest/config/
#设置国内镜像源时区
RUN apk update && \
apk upgrade && \
apk add --no-cache tzdata && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone
#安装curl
RUN apk add --no-cache curl && chmod +x /app/main
#添加health检查
HEALTHCHECK --interval=60s --timeout=3s --retries=3 CMD curl -f http://127.0.0.1:12401/api/monitor/heathcheck || exit 1
# 启动服务
CMD ["./main"]
EXPOSE 12401