11# ## STAGE 1: Dependencies and Build
22ARG BASE_IMAGE_REGISTRY=cgr.dev
3+ ARG TOOLS_NODE_VERSION=24.13.0
34ARG BUILDPLATFORM
45FROM --platform=$BUILDPLATFORM $BASE_IMAGE_REGISTRY/chainguard/wolfi-base:latest AS deps
56ENV LANG=C.UTF-8
67ENV LC_ALL=C.UTF-8
78# This is used to print the build platform in the logs
89ARG BUILDPLATFORM
10+ ARG TOOLS_NODE_VERSION
911
10- RUN --mount=type=cache,target=/var/cache/apk,rw \
11- echo "Installing on $BUILDPLATFORM" \
12- && apk update \
13- && apk add curl bash openssl unzip ca-certificates nginx supervisor \
12+ RUN echo "Installing on $BUILDPLATFORM" \
13+ && apk add --no-cache curl bash openssl unzip ca-certificates nginx supervisor "nodejs~${TOOLS_NODE_VERSION}" npm \
1414 && update-ca-certificates
1515
16- ARG TOOLS_BUN_VERSION
17- ARG TARGETARCH
18-
1916ENV DO_NOT_TRACK=1
2017ENV NEXT_TELEMETRY_DISABLED=1
21- ENV BUN_INSTALL_CACHE_DIR=/cache/bun
22- ENV BUN_INSTALL=/usr/local/bun
23- ENV NODE_ENV=production
2418ENV CYPRESS_INSTALL_BINARY=0
25- ENV PATH=$BUN_INSTALL/bin:$PATH
26-
27- # Install Bun (uses official install script)
28- # brew install oven-sh/bun/bun
29- RUN --mount=type=cache,target=/cache/bun,rw \
30- mkdir -p $BUN_INSTALL \
31- && curl -fsSL https://bun.sh/install | bash -s "bun-v$TOOLS_BUN_VERSION" \
32- && bun --version
3319
3420WORKDIR /app/ui
3521
3622# Copy package files and install dependencies
3723COPY package*.json ./
38- RUN --mount=type=cache,target=/cache/node_modules,rw \
39- bun install --frozen-lockfile \
40- && bun pm ls --all \
41- && bun pm hash
24+ RUN --mount=type=cache,target=/root/.npm,rw \
25+ npm ci
4226
4327# ## STAGE 2: Build
4428FROM --platform=$BUILDPLATFORM deps AS builder
@@ -47,35 +31,25 @@ FROM --platform=$BUILDPLATFORM deps AS builder
4731COPY . .
4832
4933# Build the application (native compilation for speed)
50- RUN --mount=type=cache,target=/cache/node_modules ,rw \
34+ RUN --mount=type=cache,target=/root/.npm ,rw \
5135 --mount=type=cache,target=/app/ui/.next/cache,rw \
5236 export NEXT_TELEMETRY_DEBUG=1 \
53- && bun install --frozen-lockfile \
54- && bun run build \
37+ && npm run build \
5538 && mkdir -p /app/ui/public
5639
5740# ## STAGE 3: Runtime
5841FROM $BASE_IMAGE_REGISTRY/chainguard/wolfi-base:latest AS final
5942ENV LANG=C.UTF-8
6043ENV LC_ALL=C.UTF-8
44+ ENV NODE_ENV=production
6145# This is used to print the build platform in the logs
6246ARG BUILDPLATFORM
47+ ARG TOOLS_NODE_VERSION
6348
64- RUN --mount=type=cache,target=/var/cache/apk,rw \
65- echo "Installing on $BUILDPLATFORM" \
66- && apk update \
67- && apk add curl bash openssl unzip ca-certificates nginx supervisor \
49+ RUN echo "Installing on $BUILDPLATFORM" \
50+ && apk add --no-cache curl bash openssl unzip ca-certificates nginx supervisor "nodejs~${TOOLS_NODE_VERSION}" \
6851 && update-ca-certificates
6952
70- ARG TOOLS_BUN_VERSION
71- ENV BUN_INSTALL=/usr/local/bun
72- ENV PATH=$BUN_INSTALL/bin:$PATH
73- # Install Bun in native arch for running (uses official install script)
74- # brew install oven-sh/bun/bun
75- RUN mkdir -p $BUN_INSTALL \
76- && curl -fsSL https://bun.sh/install | bash -s "bun-v$TOOLS_BUN_VERSION" \
77- && bun --version
78-
7953RUN mkdir -p /app/ui/public /tmp/nginx/client_temp /tmp/nginx/proxy_temp /tmp/nginx/fastcgi_temp /tmp/nginx/uwsgi_temp /tmp/nginx/scgi_temp \
8054 && addgroup -g 1001 nginx \
8155 && adduser -u 1001 -G nginx -s /bin/bash -D nextjs \
@@ -108,4 +82,4 @@ LABEL org.opencontainers.image.version="$VERSION"
10882
10983USER nextjs
11084
111- CMD ["/usr/bin/supervisord" , "-c" , "/etc/supervisor/conf.d/supervisord.conf" ]
85+ CMD ["/usr/bin/supervisord" , "-c" , "/etc/supervisor/conf.d/supervisord.conf" ]
0 commit comments