feat: update Dockerfile and README for TTS service setup and usage instructions

This commit is contained in:
王锦强
2025-03-09 13:49:32 +08:00
parent e309375c49
commit 9cf173946d
5 changed files with 107 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
# 使用官方 Golang 镜像作为构建环境
FROM golang:1.22-alpine as builder
ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn,direct
FROM golang:1.22-alpine AS builder
ENV CGO_ENABLED=0
ENV GOPROXY=https://goproxy.cn,direct
# 设置工作目录
WORKDIR /app
@@ -16,17 +16,24 @@ RUN go mod download
COPY . .
# 构建 Go 应用程序
RUN go build -o main . && ls
RUN go build -o main ./cmd/api/main.go
# 使用 scratch 作为基础镜像
# 使用 alpine 作为基础镜像
FROM alpine
# 安装 ffmpeg 和 CA 证书
RUN apk update --no-cache && \
apk add --no-cache ca-certificates ffmpeg tzdata && \
rm -rf /var/cache/apk/*
# 从 builder 阶段复制可执行文件到当前阶段
COPY --from=builder /app/main .
COPY --from=builder /app/templates ./templates
RUN apk update --no-cache && apk add --no-cache ca-certificates
ENV TZ Asia/Shanghai
COPY --from=builder /app/web ./web
COPY --from=builder /app/configs ./configs
# 设置时区
ENV TZ=Asia/Shanghai
# 暴露端口
EXPOSE 8080