chore: add node22 bun base image and tune start
This commit is contained in:
parent
eebe1a717f
commit
43548ab4b8
3 changed files with 73 additions and 32 deletions
29
Dockerfile.prod
Normal file
29
Dockerfile.prod
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Runtime image with Node 22 + Bun 1.3.2 and build toolchain preinstalled
|
||||
FROM node:22-bullseye-slim
|
||||
|
||||
ENV BUN_INSTALL=/root/.bun
|
||||
ENV PATH="$BUN_INSTALL/bin:$PATH"
|
||||
|
||||
RUN apt-get update -y \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg \
|
||||
unzip \
|
||||
build-essential \
|
||||
python3 \
|
||||
make \
|
||||
pkg-config \
|
||||
git \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Bun 1.3.2
|
||||
RUN curl -fsSL https://bun.sh/install \
|
||||
| bash -s -- bun-v1.3.2 \
|
||||
&& ln -sf /root/.bun/bin/bun /usr/local/bin/bun \
|
||||
&& ln -sf /root/.bun/bin/bun /usr/local/bin/bunx
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# We'll mount the app code at runtime; image just provides runtimes/toolchains.
|
||||
CMD ["bash"]
|
||||
|
|
@ -17,6 +17,9 @@ echo "[start-web] NEXT_PUBLIC_CONVEX_URL=${NEXT_PUBLIC_CONVEX_URL:-}"
|
|||
|
||||
# Ensure system deps for native modules (best-effort, idempotent)
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
if [ "${SKIP_APT_BOOTSTRAP:-false}" = "true" ]; then
|
||||
echo "[start-web] SKIP_APT_BOOTSTRAP=true; skipping apt bootstrap"
|
||||
else
|
||||
# Ensure curl/gnupg for NodeSource setup
|
||||
if ! command -v curl >/dev/null 2>&1; then
|
||||
apt-get update -y || true
|
||||
|
|
@ -51,15 +54,20 @@ if command -v apt-get >/dev/null 2>&1; then
|
|||
ln -sf /usr/bin/nodejs /usr/bin/node || true
|
||||
fi
|
||||
install_node
|
||||
fi
|
||||
else
|
||||
echo "[start-web] apt-get unavailable; skipping system deps install" >&2
|
||||
fi
|
||||
|
||||
# Rebuild native better-sqlite3 bindings for the current Node version
|
||||
if command -v npm >/dev/null 2>&1; then
|
||||
if [ "${SKIP_SQLITE_REBUILD:-false}" = "true" ]; then
|
||||
echo "[start-web] skipping better-sqlite3 rebuild (SKIP_SQLITE_REBUILD=true)"
|
||||
else
|
||||
echo "[start-web] rebuilding better-sqlite3 for current Node runtime"
|
||||
(npm rebuild better-sqlite3 >/dev/null 2>&1 && echo "[start-web] better-sqlite3 rebuilt") || echo "[start-web] rebuild skipped (using existing bindings)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Bun keeps its store in node_modules/.bun by default; ensure it exists and is writable
|
||||
mkdir -p node_modules/.bun >/dev/null 2>&1 || true
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ version: "3.8"
|
|||
|
||||
services:
|
||||
web:
|
||||
image: oven/bun:1.3.2
|
||||
image: sistema_web:node22-bun
|
||||
# Rodamos como root para permitir apt-get (Node 22, toolchain) no boot
|
||||
user: "root"
|
||||
working_dir: /app
|
||||
|
|
@ -31,6 +31,10 @@ services:
|
|||
REPORTS_CRON_BASE_URL: "${REPORTS_CRON_BASE_URL}"
|
||||
# Mantém o SQLite fora do repositório
|
||||
DATABASE_URL: "file:/app/data/db.sqlite"
|
||||
# Evita apt-get na inicialização porque a imagem já vem com toolchain pronta
|
||||
SKIP_APT_BOOTSTRAP: "true"
|
||||
# Desativa rebuild a cada start (já reempacotado para Node 22 na imagem)
|
||||
SKIP_SQLITE_REBUILD: "true"
|
||||
# Usado para forçar novo rollout a cada deploy (setado pelo CI)
|
||||
RELEASE_SHA: "${RELEASE_SHA:-dev}"
|
||||
deploy:
|
||||
|
|
@ -66,7 +70,7 @@ services:
|
|||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
start_period: 30s
|
||||
start_period: 120s
|
||||
|
||||
convex_backend:
|
||||
image: sistema_convex_backend:1.29.2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue