Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (44 loc) · 1.91 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (44 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Build the frontend static export (web/out) so it can be embedded into the
# Go binary below. Mirrors web/Dockerfile's build stage.
FROM --platform=$BUILDPLATFORM node:24.11.1 AS web-builder
ARG NEXT_PUBLIC_DEFAULT_RESOLVER=127.0.0.11:53
# Optional proxy settings so npm can reach the registry from restricted networks.
# Pass explicitly when behind a proxy, e.g.:
# source .env.proxy && docker build --build-arg HTTP_PROXY=$http_proxy --build-arg HTTPS_PROXY=$http_proxy ...
# The values never end up in the final image.
ARG HTTP_PROXY
ARG HTTPS_PROXY
WORKDIR /app/web
COPY web/package.json web/package-lock.json ./
RUN if [ -n "${HTTP_PROXY:-}" ] || [ -n "${HTTPS_PROXY:-}" ]; then \
npm config set proxy "${HTTP_PROXY:-${HTTPS_PROXY}}" && \
npm config set https-proxy "${HTTPS_PROXY:-${HTTP_PROXY}}"; \
fi
RUN npm ci
COPY web/ ./
# explicitly choose .env.prod
COPY web/.env.prod .env
RUN npm run build
# Stamp build version into the export, served later at /version.txt (best-effort;
# the file is generated by buildversion.sh or CI and may not exist locally)
RUN if [ -f .version.txt ]; then cp .version.txt out/.version.txt; fi
FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS builder-basis
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app/globalping
COPY go.mod go.mod
COPY go.sum go.sum
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go mod download
FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS builder
ARG TARGETOS
ARG TARGETARCH
COPY --from=builder-basis /go/pkg /go/pkg
WORKDIR /app/globalping
COPY . .
# Freshly built frontend assets from the web-builder stage, embedded via go:embed
COPY --from=web-builder /app/web/out ./web/out
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o bin/globalping ./cmd/globalping
FROM debian:bookworm
RUN \
apt-get update -y && apt-get install -y ca-certificates fontconfig fonts-noto-mono
COPY --from=builder /app/globalping/bin/globalping /usr/local/bin/globalping