build(docker): optimize docker image size and build process

Use slim base image and install build dependencies only when needed
Rebuild native modules during install for production compatibility
This commit is contained in:
lklynet
2026-01-01 23:16:42 -05:00
parent 0f2fddab6d
commit 7db91bb594
+10 -2
View File
@@ -1,10 +1,18 @@
FROM node:18
FROM node:18-bullseye-slim
WORKDIR /app
# Install build dependencies for native modules
RUN apt-get update && apt-get install -y \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
COPY package*.json ./
RUN npm install --production
# Install dependencies with full rebuild
RUN npm install --production --build-from-source
COPY server.js ./