From 7887f4fd32d55d97102de3fdb34d57b6a6ff516f Mon Sep 17 00:00:00 2001 From: nghionpoint Date: Fri, 10 Apr 2026 10:47:37 +0700 Subject: [PATCH] Parameterize Bun image and improve package management in Dockerfile - Introduced `BUN_IMAGE` build argument for flexibility in specifying the Bun image version. - Added `apk --no-cache upgrade` for ensuring up-to-date packages. - Streamlined apk package additions for improved dependency management. --- Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1bb6925..e5d72cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,11 @@ # syntax=docker/dockerfile:1.7 -FROM oven/bun:1-alpine AS base +ARG BUN_IMAGE=oven/bun:1.3.2-alpine +FROM ${BUN_IMAGE} AS base WORKDIR /app FROM base AS builder -RUN apk add --no-cache nodejs npm python3 make g++ linux-headers +RUN apk --no-cache upgrade && apk --no-cache add nodejs npm python3 make g++ linux-headers COPY package.json ./ RUN --mount=type=cache,target=/root/.npm \ @@ -14,7 +15,7 @@ COPY . ./ ENV NEXT_TELEMETRY_DISABLED=1 RUN npm run build -FROM oven/bun:1-alpine AS runner +FROM ${BUN_IMAGE} AS runner WORKDIR /app LABEL org.opencontainers.image.title="9router" @@ -36,7 +37,7 @@ COPY --from=builder /app/node_modules/node-forge ./node_modules/node-forge RUN mkdir -p /app/data && chown -R bun:bun /app # Fix permissions at runtime (handles mounted volumes) -RUN apk add --no-cache su-exec && \ +RUN apk --no-cache upgrade && apk --no-cache add su-exec && \ printf '#!/bin/sh\nchown -R bun:bun /app/data 2>/dev/null\nexec su-exec bun "$@"\n' > /entrypoint.sh && \ chmod +x /entrypoint.sh