repair-agent 5e3f0653c9
All checks were successful
Build and Deploy Backend / build-and-deploy (push) Successful in 3m48s
fix bug
2026-03-03 15:33:00 +08:00

39 lines
1.2 KiB
Docker
Raw Permalink 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.

# ============================================================
# hw-ws-service Dockerfile — 多阶段构建(国内 CI 优化版)
# 优化go mod vendor 跳过网络下载Alpine 阿里云源加速
# ============================================================
# ---- 构建阶段 ----
FROM golang:1.23-alpine AS builder
# Alpine 换国内源 + 安装编译依赖
RUN sed -i 's#dl-cdn.alpinelinux.org#mirrors.aliyun.com#g' /etc/apk/repositories && \
apk add --no-cache gcc musl-dev opus-dev opusfile-dev
WORKDIR /app
COPY . .
# vendor 模式:依赖已随代码提交,无需联网下载
# CGO_ENABLED=1 必须开启hraban/opus 是 CGO 库)
RUN --mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=1 GOOS=linux \
go build \
-mod=vendor \
-trimpath \
-ldflags="-s -w" \
-o hw-ws-service \
./cmd/main.go
# ---- 运行阶段 ----
FROM alpine:3.20
RUN sed -i 's#dl-cdn.alpinelinux.org#mirrors.aliyun.com#g' /etc/apk/repositories && \
apk add --no-cache opus opusfile ffmpeg ca-certificates && \
addgroup -S hwws && adduser -S hwws -G hwws
COPY --from=builder /app/hw-ws-service /hw-ws-service
USER hwws
EXPOSE 8888
ENTRYPOINT ["/hw-ws-service"]