Update Dockerfile
Browse files- Dockerfile +30 -12
Dockerfile
CHANGED
|
@@ -1,10 +1,28 @@
|
|
| 1 |
-
#
|
| 2 |
-
FROM node:18-alpine
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
#
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
RUN apk add --no-cache \
|
| 9 |
git \
|
| 10 |
python3 \
|
|
@@ -15,17 +33,17 @@ RUN apk add --no-cache \
|
|
| 15 |
ttf-freefont \
|
| 16 |
ffmpeg
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
COPY
|
| 26 |
|
| 27 |
-
#
|
| 28 |
EXPOSE 7860
|
| 29 |
|
| 30 |
-
#
|
| 31 |
CMD ["node", "index.js"]
|
|
|
|
| 1 |
+
# Stage 1: Build Stage
|
| 2 |
+
FROM node:18-alpine AS build
|
| 3 |
+
|
| 4 |
+
# Set environment variables for Node.js
|
| 5 |
+
ENV NODE_ENV=production
|
| 6 |
|
| 7 |
+
# Set working directory
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
+
# Copy package.json and package-lock.json
|
| 11 |
+
COPY package*.json ./
|
| 12 |
+
|
| 13 |
+
# Install production dependencies
|
| 14 |
+
RUN npm install --only=production
|
| 15 |
+
|
| 16 |
+
# Copy the entire application
|
| 17 |
+
COPY . .
|
| 18 |
+
|
| 19 |
+
# Remove any development dependencies to keep the build clean
|
| 20 |
+
RUN npm prune --production
|
| 21 |
+
|
| 22 |
+
# Stage 2: Final Stage
|
| 23 |
+
FROM node:18-alpine
|
| 24 |
+
|
| 25 |
+
# Install required system packages
|
| 26 |
RUN apk add --no-cache \
|
| 27 |
git \
|
| 28 |
python3 \
|
|
|
|
| 33 |
ttf-freefont \
|
| 34 |
ffmpeg
|
| 35 |
|
| 36 |
+
# Clean up package cache to keep image size small
|
| 37 |
+
RUN rm -rf /var/cache/apk/*
|
| 38 |
|
| 39 |
+
# Set the working directory
|
| 40 |
+
WORKDIR /app
|
| 41 |
|
| 42 |
+
# Copy only the necessary files from the build stage
|
| 43 |
+
COPY --from=build /app .
|
| 44 |
|
| 45 |
+
# Expose the port the app runs on
|
| 46 |
EXPOSE 7860
|
| 47 |
|
| 48 |
+
# Command to run the application
|
| 49 |
CMD ["node", "index.js"]
|