update
This commit is contained in:
1 parent
82bbaa0e83
commit
edee33416f
1 file changed
+6
-24
+6
-24
@@ -1,43 +1,25 @@
|
|||||||
# ========== STAGE 1: Build ==========
|
# ===== STAGE 1: Dependency Installation =====
|
||||||
FROM node:18 AS builder
|
FROM node:18 AS deps
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy only what's needed to install dependencies first (for better cache)
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# Install dependencies without unnecessary cache
|
|
||||||
RUN npm ci --omit=dev
|
RUN npm ci --omit=dev
|
||||||
|
|
||||||
# Then copy the rest of the source
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build the app (modify this command if you're not using a build script)
|
# ===== STAGE 2: Runtime =====
|
||||||
RUN npm run build
|
FROM node:18-slim
|
||||||
|
|
||||||
|
|
||||||
# ========== STAGE 2: Runtime ==========
|
|
||||||
FROM node:18-slim AS runtime
|
|
||||||
|
|
||||||
# Install runtime dependencies
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
tini \
|
tini \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy built app from builder stage
|
COPY --from=deps /app /app
|
||||||
COPY --from=builder /app/dist ./dist
|
|
||||||
COPY --from=builder /app/package*.json ./
|
|
||||||
|
|
||||||
# Set correct permissions if needed
|
|
||||||
RUN chown -R node:node /app
|
|
||||||
|
|
||||||
USER node
|
|
||||||
|
|
||||||
# Expose port (adjust if needed)
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Start the app
|
|
||||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||||
CMD ["node", "dist/server.js"]
|
CMD ["node", "server.js"]
|
||||||
Reference in new issue
Block a user