Files
Wormhole/Dockerfile
T
renjue ddee5a9ebb
CI / docker (push) Successful in 6m41s
perf: 纯 Go SQLite 驱动并简化 Docker 构建
改用 glebarez/sqlite 以禁用 CGO,去掉交叉编译工具链;Dockerfile 基镜像与 Prism CI 模板对齐以加速多架构构建。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-23 16:57:59 +08:00

75 lines
1.9 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.
# Wormhole 内网穿透 + 反向代理网关(Go + Vue 管理台)
#
# 构建:
# docker build -t wormhole:latest .
#
# 服务端:
# docker run -d --name wormhole \
# -p 8529:8529 -p 8528:8528 -p 8081:8081 -p 8443:8443 \
# -v wormhole-data:/app/data \
# wormhole:latest
#
# Agent:
# docker run -d --name wormhole-agent --restart=unless-stopped --network host \
# wormhole:latest agent -server <服务端IP>:8528 -key <verify_key>
#
# 生产镜像由 Gitea Actions 构建,见 README
# syntax=docker/dockerfile:1
# 基础镜像默认 Docker HubCI 默认 1Panel 加速(docker.1panel.live),本地可传:
# docker build --build-arg IMAGE_PREFIX=docker.1panel.live/library/ -t wormhole:latest .
ARG IMAGE_PREFIX=
FROM --platform=$BUILDPLATFORM ${IMAGE_PREFIX}node:20-alpine AS web-builder
WORKDIR /src/web
COPY web/package.json web/package-lock.json web/.npmrc ./
RUN npm ci
COPY web/ ./
RUN npm run build
FROM --platform=$BUILDPLATFORM ${IMAGE_PREFIX}golang:1.25-alpine AS go-builder
ARG TARGETARCH
ARG GOPROXY=https://goproxy.cn,direct
ARG GOSUMDB=sum.golang.google.cn
ENV GOPROXY=${GOPROXY} GOSUMDB=${GOSUMDB}
WORKDIR /src
COPY go.mod go.sum go.env ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY cmd/ ./cmd/
COPY internal/ ./internal/
COPY web/embed.go ./web/
COPY --from=web-builder /src/web/dist ./web/dist
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux GOARCH="$TARGETARCH" \
go build -ldflags="-w -s" -o /wormhole ./cmd/wormhole
FROM ${IMAGE_PREFIX}alpine:3.20
RUN apk add --no-cache ca-certificates tzdata \
&& addgroup -S wormhole \
&& adduser -S wormhole -G wormhole
WORKDIR /app
COPY --from=go-builder /wormhole /usr/local/bin/wormhole
RUN mkdir -p /app/data \
&& chown -R wormhole:wormhole /app
USER wormhole
VOLUME ["/app/data"]
EXPOSE 8529 8528 8081 8443
ENTRYPOINT ["/usr/local/bin/wormhole"]
CMD ["server"]