mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 20:23:39 +09:00
The remaining Go builder stages, plus the kube-ovn, console and piraeus-server builders, ran on the target platform. A multi-platform build therefore ran the whole compiler under QEMU: slow, and for Go unreliable, as the migration-controller Dockerfile already records a "found bad pointer in Go heap" crash from exactly that. The builders now run on $BUILDPLATFORM and produce the target architecture from TARGETARCH. Two builders only produced the right architecture because they were emulated. token-proxy ran `go build` with no GOOS/GOARCH, and kube-ovn calls upstream `make build-go`, which hardcodes GOARCH=amd64 even on an arm64 build. On a native builder both would have shipped host binaries inside the other architecture's image, and nothing fails until a node of that architecture starts the container. token-proxy now passes the target explicitly; kube-ovn picks build-go or its arm64 twin build-go-arm from TARGETARCH. The console builder emits static JS and linstor-server's debian/control declares every package Architecture: all, so both run natively without a target. A bats test requires every stage that compiles to sit on a BUILDPLATFORM FROM and to read TARGETARCH or TARGETPLATFORM on a RUN or ENV line. A bare ARG declaration does not count, which is what let token-proxy through. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la>
110 lines
3.6 KiB
Docker
110 lines
3.6 KiB
Docker
ARG NODE_VERSION=22-alpine@sha256:0a7108bf6c7bf5de370ffb1a3ed6be93d405b43ff159f681a8d18c0e2bc2e402
|
|
|
|
# Stage 1: Install dependencies and build
|
|
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS builder
|
|
|
|
ARG APP_VERSION
|
|
ENV VITE_APP_VERSION=${APP_VERSION}
|
|
|
|
# Pin to the version in package.json's packageManager field so the image build
|
|
# matches CI and the lockfile, rather than drifting to a newer pnpm major.
|
|
RUN corepack enable && corepack prepare pnpm@11.1.2 --activate
|
|
|
|
WORKDIR /src
|
|
|
|
# Workspace manifests first for cached installs.
|
|
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
|
|
COPY apps/console/package.json apps/console/
|
|
COPY packages/ui/package.json packages/ui/
|
|
COPY packages/types/package.json packages/types/
|
|
COPY packages/k8s-client/package.json packages/k8s-client/
|
|
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
COPY apps/console/ apps/console/
|
|
COPY packages/ packages/
|
|
COPY tsconfig.base.json ./
|
|
|
|
RUN pnpm --filter @cozystack/console build
|
|
|
|
# Stage 2: Serve with nginx
|
|
FROM nginxinc/nginx-unprivileged:1.29-alpine@sha256:0c79d56aee561a1d81c63f00eee5fb5fe29279560cdc55e91425133104c7fbe6
|
|
|
|
COPY --from=builder /src/apps/console/dist /usr/share/nginx/html
|
|
|
|
COPY <<'EOF' /etc/nginx/conf.d/default.conf
|
|
map $http_upgrade $connection_upgrade {
|
|
default upgrade;
|
|
'' close;
|
|
}
|
|
|
|
# An OIDC access token with many group claims pushes the Cookie header past the
|
|
# 8k default, and a header field must fit in a single buffer. Kept here rather
|
|
# than inside the server block: a field read before the Host header has selected
|
|
# the virtual server is measured against the default server's buffers, so the
|
|
# same lines inside a server block cover this one only while it stays default.
|
|
client_header_buffer_size 16k;
|
|
large_client_header_buffers 4 16k;
|
|
|
|
server {
|
|
listen 8080 default_server;
|
|
listen [::]:8080 default_server;
|
|
server_name _;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Kubernetes API proxy for both core and aggregated groups.
|
|
# Chunked-encoding watches require proxy_buffering off and a long timeout.
|
|
location /apis {
|
|
proxy_http_version 1.1;
|
|
proxy_buffering off;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection $connection_upgrade;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header Host kubernetes.default.svc;
|
|
proxy_read_timeout 86400s;
|
|
proxy_send_timeout 86400s;
|
|
proxy_pass https://kubernetes.default.svc:443;
|
|
}
|
|
|
|
location /api {
|
|
proxy_http_version 1.1;
|
|
proxy_buffering off;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection $connection_upgrade;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header Host kubernetes.default.svc;
|
|
proxy_read_timeout 86400s;
|
|
proxy_send_timeout 86400s;
|
|
proxy_pass https://kubernetes.default.svc:443;
|
|
}
|
|
|
|
# /k8s prefix for VNC WebSocket compatibility
|
|
location /k8s/ {
|
|
proxy_http_version 1.1;
|
|
proxy_buffering off;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection $connection_upgrade;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header Host kubernetes.default.svc;
|
|
proxy_read_timeout 86400s;
|
|
proxy_send_timeout 86400s;
|
|
rewrite /k8s/(.*) /$1 break;
|
|
proxy_pass https://kubernetes.default.svc:443;
|
|
}
|
|
|
|
# SPA fallback: serve index.html for all frontend routes.
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
location /healthcheck {
|
|
access_log off;
|
|
return 200 "Healthy\n";
|
|
}
|
|
}
|
|
EOF
|
|
|
|
EXPOSE 8080
|