-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (41 loc) · 1.71 KB
/
Copy pathDockerfile
File metadata and controls
57 lines (41 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Base: shared system dependencies for both dev and prod.
# =======================================================
FROM node:24-slim AS base
# Install Chromium and minimal runtime dependencies.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
chromium \
fonts-liberation \
&& rm -rf /var/lib/apt/lists/*
# Tell the app where Chromium lives.
ENV CHROMIUM_PATH=/usr/bin/chromium
# Set the working directory inside the container.
WORKDIR /app
# Development: full dependencies, source mounted at runtime.
# ==========================================================
FROM base AS dev
# Copy dependency manifests first for optimal layer caching.
COPY package.json package-lock.json .npmrc ./
# Install all dependencies (including devDependencies).
RUN npm ci
# Create logs directory owned by the non-root node user.
RUN mkdir -p logs && chown -R node:node /app
# Switch to the non-root user for better security.
USER node
# Start the application with the environment variables from the `.env` file.
CMD ["node", "--env-file=.env", "src/app.ts"]
# Production: lean image with source baked in.
# ============================================
FROM base AS prod
# Copy dependency manifests first for optimal layer caching.
COPY package.json package-lock.json .npmrc ./
# Install production dependencies only.
RUN npm ci --omit=dev
# Copy application source (except files ignored by `.dockerignore`).
COPY src/ src/
# Create logs directory owned by the non-root node user.
RUN mkdir -p logs && chown -R node:node /app
# Switch to the non-root user for better security.
USER node
# Start the application with the environment variables from the `.env` file.
CMD ["node", "--env-file=.env", "src/app.ts"]