Files
frps-console/Dockerfile
T

46 lines
1.3 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.
# ============================================================
# 构建阶段
# ============================================================
FROM golang:alpine AS builder
WORKDIR /app
# 复制依赖文件(如果存在 go.sum 则一并复制)
COPY go.mod go.sum* ./
RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go mod download
# 复制全部源码(包含 bin/ 和 static/
COPY . .
# 编译 Linux 版(CGO_ENABLED=0 静态编译,-p 1 降低内存峰值)
RUN CGO_ENABLED=0 GOOS=linux go build -p 1 -ldflags="-s -w" -o frps-console .
# ============================================================
# 运行阶段
# ============================================================
FROM alpine:latest
# 安装 ca-certificates 和 tzdata(确保 HTTPS 和时区正常)
RUN apk --no-cache add ca-certificates tzdata
WORKDIR /app
# 从构建阶段复制编译好的二进制
COPY --from=builder /app/frps-console /app/frps-console
# 创建数据目录(用于持久化 db 和日志)
RUN mkdir -p /app/data
# 暴露端口(与 deploy.sh 中默认端口一致)
EXPOSE 9365
# 环境变量(可被 docker run -e 覆盖)
ENV PORT=9365
ENV TZ=Asia/Shanghai
# 数据卷(持久化数据库、配置、日志)
VOLUME ["/app/data"]
# 启动
ENTRYPOINT ["/app/frps-console"]