FROM node:22 AS web-builder WORKDIR /web/frpc COPY web/frpc/ ./ RUN npm ci RUN npm run build FROM golang:1.25 AS building WORKDIR /building COPY . . COPY --from=web-builder /web/frpc/dist /building/web/frpc/dist ENV CGO_ENABLED=0 RUN env CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -tags frpc -o bin/frpc ./cmd/frpc FROM alpine:3.23 RUN apk add --no-cache tzdata ca-certificates COPY --from=building /building/bin/frpc /usr/bin/frpc ENTRYPOINT ["/usr/bin/frpc"]
# Dependency caches and environment .git .gitignore node_modules/ web/frpc/node_modules/ vendor/ dist/ build/ tmp/ *.log *.out *.cache *.tmp .DS_Store .idea/ .vscode/ # Avoid accidentally sending large artifacts bin/
Concerns: Final image relies on embedding frontend assets; ensure the Go code embeds the dist directory (or that assets are available at runtime), otherwise the server may fail to serve the frontend., Frontend build step depends on npm and network access; verify that web/frpc/dist is present and that the build environment allows npm ci and npm run build (could be brittle in restricted CI environments). Smoke [PASS]: /usr/bin/frpc --version Smoke [PASS]: /usr/bin/frpc --help Smoke [PASS]: test -x /usr/bin/frpc