Skip to content

Commit eb484c6

Browse files
committed
simplify dockerfile
1 parent 53ab680 commit eb484c6

File tree

1 file changed

+11
-27
lines changed

1 file changed

+11
-27
lines changed

Dockerfile

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,22 @@
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
64
RUN 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
189
WORKDIR /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
2816
COPY . .
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
3619
EXPOSE 3000
3720

38-
CMD ["node", "app.js"]
21+
# Define the command to run your app
22+
CMD [ "node", "app.js" ]

0 commit comments

Comments
 (0)