File tree Expand file tree Collapse file tree 1 file changed +11
-27
lines changed
Expand file tree Collapse file tree 1 file changed +11
-27
lines changed Original file line number Diff line number Diff line change 1- # ------------ BASE STAGE ------------
2- FROM node:20-slim AS base
3- WORKDIR /usr/src/app
1+ FROM node:20-slim
42
5- # Install only required runtime packages (ffmpeg minimal)
3+ # Install ffmpeg and clean up in a single layer
64RUN apt-get update && \
7- apt-get install -y --no-install-recommends ffmpeg && \
5+ apt-get install -y ffmpeg --no-install-recommends && \
86 rm -rf /var/lib/apt/lists/*
97
10- COPY package*.json ./
11-
12- # Install only production dependencies
13- RUN npm install --omit=dev
14-
15- # ------------ FINAL STAGE ------------
16- FROM node:20-slim
17-
8+ # Set the working directory
189WORKDIR /usr/src/app
1910
20- # Copy ffmpeg binary from base image (much smaller)
21- COPY --from=base /usr/bin/ffmpeg /usr/bin/
22- COPY --from=base /usr/lib/ /usr/lib/
23-
24- # Copy node_modules from base stage
25- COPY --from=base /usr/src/app/node_modules ./node_modules
11+ # Copy package files and install dependencies first to leverage caching
12+ COPY package*.json ./
13+ RUN npm install --production
2614
27- # Copy application code
15+ # Copy the rest of your application code
2816COPY . .
2917
30- # Create non-root user
31- RUN useradd --user-group --create-home --shell /bin/false appuser && \
32- mkdir -p /usr/src/app/logs && \
33- chown -R appuser:appuser /usr/src/app
34-
35- USER appuser
18+ # Expose the port the app runs on
3619EXPOSE 3000
3720
38- CMD ["node" , "app.js" ]
21+ # Define the command to run your app
22+ CMD [ "node" , "app.js" ]
You can’t perform that action at this time.
0 commit comments