Files
media/Dockerfile

55 lines
1.5 KiB
Docker
Raw Normal View History

2026-05-19 14:33:06 +08:00
# 阶段1: 构建
FROM golang:1.26-alpine AS builder
RUN apk add --no-cache git ca-certificates tzdata
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
ENV CGO_ENABLED=0
ENV GOTOOLCHAIN=auto
ENV GOPRIVATE=gitea.com/red-future/common
# 配置git使用私有Gitea仓库
RUN git config --global url."http://x-token-auth:9b31146aa8c10a7cb4f2e49dcee0934a223be1076289810e1ad98b968066c2bc@116.204.74.41:3000/red-future/common.git".insteadOf "https://gitea.com/red-future/common.git" && \
git config --global credential.helper store
WORKDIR /build
COPY . .
RUN go mod download && go mod tidy
RUN go build -ldflags="-s -w" -o main ./main.go
# 阶段2: 运行
FROM alpine:3.19
2026-05-20 11:32:39 +08:00
# 安装运行时依赖: ca-certificates(HTTPS), tzdata(时区), ffmpeg(音视频处理)
RUN apk add --no-cache ca-certificates tzdata ffmpeg bash
# 安装 Python3 和 pip用于 whisper 语音识别)
RUN apk add --no-cache python3 py3-pip && \
pip3 install --no-cache-dir --break-system-packages openai-whisper 2>/dev/null || \
pip3 install --no-cache-dir openai-whisper
2026-05-19 14:33:06 +08:00
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
WORKDIR /app
COPY --from=builder /build/main .
COPY --from=builder /build/config.yml ./
RUN mkdir -p /app/resource/log/run \
/app/resource/log/server \
&& adduser -D -u 1000 appuser \
&& chown -R appuser:appuser /app
USER appuser
2026-05-20 11:39:01 +08:00
EXPOSE 3010
2026-05-19 14:33:06 +08:00
CMD ["./main"]