Files
frpc-console/Dockerfile
T

48 lines
1.2 KiB
Docker
Raw 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
# 复制依赖文件
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 保证静态编译)
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-s -w" \
-o frpc-console .
# ============================================================
# 运行阶段
# ============================================================
FROM alpine:latest
# 安装 ca-certificates 和 tzdata(确保 HTTPS 和时区正常)
RUN apk --no-cache add ca-certificates tzdata sqlite
WORKDIR /app
# 从构建阶段复制编译好的二进制
COPY --from=builder /app/frpc-console /app/frpc-console
# 创建数据目录(用于持久化 db 和日志)
RUN mkdir -p /app/data
# 暴露端口(默认 9300
EXPOSE 9300
# 环境变量
ENV PORT=9300
ENV TZ=Asia/Shanghai
# 数据卷(持久化数据库、配置、日志)
VOLUME ["/app/data"]
# 启动
ENTRYPOINT ["/app/frpc-console"]