Spaces:
Runtime error
Runtime error
Create Dockerfile
Browse files- Dockerfile +57 -0
Dockerfile
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ---- Stage 1: Build the TypeScript project ----
|
| 2 |
+
# We use the full Node.js image to build the app and name this stage "builder".
|
| 3 |
+
FROM node:20-bullseye-slim AS builder
|
| 4 |
+
|
| 5 |
+
# Set the working directory
|
| 6 |
+
WORKDIR /app
|
| 7 |
+
|
| 8 |
+
# Enable pnpm, the package manager you're using
|
| 9 |
+
RUN corepack enable
|
| 10 |
+
|
| 11 |
+
# Copy only the necessary files to install dependencies
|
| 12 |
+
# This leverages Docker's layer caching for faster rebuilds.
|
| 13 |
+
COPY package.json pnpm-lock.yaml* ./
|
| 14 |
+
|
| 15 |
+
# Install ALL dependencies, including devDependencies like 'typescript' needed for the build
|
| 16 |
+
RUN pnpm install
|
| 17 |
+
|
| 18 |
+
# Copy the rest of your source code
|
| 19 |
+
COPY . .
|
| 20 |
+
|
| 21 |
+
# Run the build script ("tsc") from your package.json.
|
| 22 |
+
# This creates the essential '/dist' folder with your compiled JavaScript.
|
| 23 |
+
RUN pnpm build
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
# ---- Stage 2: Create the final, lightweight production image ----
|
| 27 |
+
# We start from a fresh, clean base image to keep it small and secure.
|
| 28 |
+
FROM node:20-bullseye-slim
|
| 29 |
+
|
| 30 |
+
# Install only essential system dependencies. ffmpeg is often needed for Baileys media handling.
|
| 31 |
+
RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg && \
|
| 32 |
+
apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 33 |
+
|
| 34 |
+
# Set the working directory
|
| 35 |
+
WORKDIR /app
|
| 36 |
+
|
| 37 |
+
# Enable pnpm
|
| 38 |
+
RUN corepack enable
|
| 39 |
+
|
| 40 |
+
# Switch to the built-in, non-root 'node' user for better security
|
| 41 |
+
USER node
|
| 42 |
+
|
| 43 |
+
# Copy dependency files from the context
|
| 44 |
+
COPY --chown=node:node package.json pnpm-lock.yaml* ./
|
| 45 |
+
|
| 46 |
+
# Install ONLY production dependencies, skipping devDependencies
|
| 47 |
+
RUN pnpm install --prod
|
| 48 |
+
|
| 49 |
+
# Copy the compiled code from the 'builder' stage into our final image
|
| 50 |
+
COPY --chown=node:node --from=builder /app/dist ./dist
|
| 51 |
+
|
| 52 |
+
# Create a directory for session data as the 'node' user
|
| 53 |
+
# For Hugging Face, you MUST make this persistent in your README.md
|
| 54 |
+
RUN mkdir ./auth
|
| 55 |
+
|
| 56 |
+
# Set the command to run your application using the "start" script.
|
| 57 |
+
CMD [ "pnpm", "start" ]
|