优化 Docker 构建:启用 BuildKit + 使用阿里云 Alpine 镜像源加速
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Failing after 4s
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Failing after 4s
This commit is contained in:
@@ -42,12 +42,12 @@ jobs:
|
||||
|
||||
- name: 构建 API 镜像
|
||||
run: |
|
||||
docker build -f Dockerfile.api -t ${{ env.API_IMAGE }}:${{ steps.tag.outputs.tag }} .
|
||||
DOCKER_BUILDKIT=1 docker build -f Dockerfile.api -t ${{ env.API_IMAGE }}:${{ steps.tag.outputs.tag }} .
|
||||
docker tag ${{ env.API_IMAGE }}:${{ steps.tag.outputs.tag }} ${{ env.API_IMAGE }}:${{ github.sha }}
|
||||
|
||||
- name: 构建 Worker 镜像
|
||||
run: |
|
||||
docker build -f Dockerfile.worker -t ${{ env.WORKER_IMAGE }}:${{ steps.tag.outputs.tag }} .
|
||||
DOCKER_BUILDKIT=1 docker build -f Dockerfile.worker -t ${{ env.WORKER_IMAGE }}:${{ steps.tag.outputs.tag }} .
|
||||
docker tag ${{ env.WORKER_IMAGE }}:${{ steps.tag.outputs.tag }} ${{ env.WORKER_IMAGE }}:${{ github.sha }}
|
||||
|
||||
- name: 推送镜像到 Registry
|
||||
|
||||
@@ -34,8 +34,11 @@ RUN go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate
|
||||
# ================================
|
||||
FROM alpine:3.19
|
||||
|
||||
# 使用阿里云镜像源加速
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
|
||||
# 安装运行时依赖
|
||||
RUN apk add --no-cache ca-certificates tzdata bash curl
|
||||
RUN apk add --no-cache ca-certificates tzdata bash
|
||||
|
||||
# 设置时区
|
||||
ENV TZ=Asia/Shanghai
|
||||
@@ -65,9 +68,9 @@ USER appuser
|
||||
# 暴露端口
|
||||
EXPOSE 8088
|
||||
|
||||
# 健康检查
|
||||
# 健康检查(使用 Alpine 自带的 wget)
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||||
CMD curl -f http://localhost:8088/health || exit 1
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:8088/health || exit 1
|
||||
|
||||
# 启动命令
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
||||
@@ -31,6 +31,9 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
# ================================
|
||||
FROM alpine:3.19
|
||||
|
||||
# 使用阿里云镜像源加速
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
|
||||
# 安装运行时依赖
|
||||
RUN apk add --no-cache ca-certificates tzdata bash
|
||||
|
||||
|
||||
Reference in New Issue
Block a user