Files
tsrun/Dockerfile
T
dmgnr 6aec28dbff
Deploy tsrun / deploy (push) Successful in 2m27s
chore: tighten bootstrap text and copy order
2026-07-22 15:03:48 +00:00

35 lines
1.5 KiB
Docker

FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS go-builder
WORKDIR /app
RUN apk add --no-cache bash curl unzip upx
COPY go.mod go.sum ./
RUN go mod download
COPY cmd ./cmd
COPY internal ./internal
COPY secrets ./secrets
RUN test -f secrets/tsrun.manifest.json
RUN curl -fsSL "https://www.wintun.net/builds/wintun-0.14.1.zip" -o /tmp/wintun.zip \
&& unzip -p /tmp/wintun.zip wintun/bin/amd64/wintun.dll > internal/runtime/full/wintun.dll
RUN go run ./cmd/buildblob -in secrets/tsrun.manifest.json -out internal/embedded/blob_gen.go
RUN GOOS=linux GOARCH=amd64 go build -trimpath -ldflags='-s -w -buildid=' -o /out/tsrun-linux ./cmd/tsrun
RUN GOOS=windows GOARCH=amd64 go build -trimpath -ldflags='-s -w -buildid=' -o /out/tsrun.exe ./cmd/tsrun
RUN cp /out/tsrun-linux /out/tsrun-linux-upx && upx --best --lzma /out/tsrun-linux-upx
RUN cp /out/tsrun.exe /out/tsrun-upx.exe && upx --best --lzma /out/tsrun-upx.exe
FROM --platform=$BUILDPLATFORM oven/bun:1.3.14-alpine AS bun-builder
WORKDIR /app
COPY server ./server
RUN bun build --target bun --minify --outfile /out/server.js ./server/index.ts
FROM --platform=$TARGETPLATFORM oven/bun:1.3.14-alpine
WORKDIR /app
COPY --from=go-builder /out/tsrun-linux ./dist/tsrun-linux
COPY --from=go-builder /out/tsrun-linux-upx ./dist/tsrun-linux-upx
COPY --from=go-builder /out/tsrun.exe ./dist/tsrun.exe
COPY --from=go-builder /out/tsrun-upx.exe ./dist/tsrun-upx.exe
COPY --from=bun-builder /out/server.js ./server.js
EXPOSE 3000
CMD ["bun", "./server.js"]