chtues2a / Dockerfile
rr1's picture
Update Dockerfile
4761c24 verified
raw
history blame contribute delete
809 Bytes
# 使用 Golang 镜像作为构建阶段
FROM golang AS builder
# 设置环境变量
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
TZ=Asia/Shanghai \
ROUTE_PREFIX=hf
# 设置工作目录
WORKDIR /build
# 安装 git
RUN apt-get update && apt-get install -y git
# 使用 git clone 获取源码
RUN git clone https://github.com/renqabs/chteus2a.git .
# 下载依赖
RUN go mod download
# 构建可执行文件
RUN go build -trimpath -ldflags "-s -w" -o /app/chutesai2api
# 使用 Alpine 镜像作为最终镜像
FROM alpine
# 安装基本的运行时依赖
RUN apk --no-cache add ca-certificates tzdata
# 从构建阶段复制可执行文件
COPY --from=builder /app/chutesai2api /chutesai2api
# 暴露端口
EXPOSE 7011
WORKDIR /app/chutesai2api/data
ENTRYPOINT ["/chutesai2api"]