understanding commited on
Commit
6e8d7df
·
verified ·
1 Parent(s): 8f7e7e8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -33
Dockerfile CHANGED
@@ -1,57 +1,32 @@
 
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" ]
 
1
+
2
  # ---- Stage 1: Build the TypeScript project ----
 
3
  FROM node:20-bullseye-slim AS builder
4
 
5
+ # Install system dependencies needed for the build, INCLUDING git
6
+ RUN apt-get update && apt-get install -y --no-install-recommends git && \
7
+ apt-get clean && rm -rf /var/lib/apt/lists/*
8
 
9
+ WORKDIR /app
10
  RUN corepack enable
 
 
 
11
  COPY package.json pnpm-lock.yaml* ./
 
 
12
  RUN pnpm install
 
 
13
  COPY . .
 
 
 
14
  RUN pnpm build
15
 
16
 
17
  # ---- Stage 2: Create the final, lightweight production image ----
 
18
  FROM node:20-bullseye-slim
19
 
20
+ # Install system dependencies needed for runtime, INCLUDING git
21
+ RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg git && \
22
  apt-get clean && rm -rf /var/lib/apt/lists/*
23
 
 
24
  WORKDIR /app
 
 
25
  RUN corepack enable
 
 
26
  USER node
 
 
27
  COPY --chown=node:node package.json pnpm-lock.yaml* ./
 
 
28
  RUN pnpm install --prod
 
 
29
  COPY --chown=node:node --from=builder /app/dist ./dist
30
+ RUN mkdir ./sessions
31
 
 
 
 
 
 
32
  CMD [ "pnpm", "start" ]