understanding commited on
Commit
a8498e2
·
verified ·
1 Parent(s): 7a67f1d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -13
Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
  # --- Stage 1: Base Setup ---
2
 
3
- # Use Node.js 22 slim version as the base image
4
- FROM node:22-slim AS base
5
 
6
  # Set environment variables
7
  ENV NODE_ENV=development \
@@ -22,14 +22,15 @@ WORKDIR /app
22
 
23
  # --- Copy and Chown Before Corepack ---
24
  # Copy package.json and pnpm lock file first
 
25
  COPY package.json pnpm-lock.yaml* ./
26
 
27
- # Change ownership of the /app directory to the 'node' user
28
- # This ensures that copied files get the correct ownership.
29
  RUN chown -R node:node /app
30
 
31
  # --- PNPM Activation ---
32
- # Enable corepack (built into Node >=16.13) to manage pnpm
33
  RUN corepack enable
34
 
35
  # Verify pnpm is active and check its version (optional, for confirmation)
@@ -43,21 +44,21 @@ RUN pnpm install --frozen-lockfile
43
  # --- Stage 3: Build & Runtime Setup ---
44
 
45
  # Copy the rest of your application code
 
46
  COPY . .
47
 
48
- # --- MODIFIED SECTION ---
49
- # Create the directories (dist removed) and set permissions to 777 (Use with caution!)
50
- # WARNING: chmod 777 is a potential security risk. Grants full access to everyone.
51
- RUN mkdir -p ./session ./downloads ./auth_info_baileys && \
52
- chmod -R 777 ./session ./downloads ./auth_info_baileys
53
- # --- END OF MODIFIED SECTION ---
54
 
55
- # Switch to the non-root 'node' user (still recommended for running the process)
56
  USER node
57
 
58
- # Expose the port your application will run on (as requested)
59
  EXPOSE 7860
60
 
61
  # The command to run your application using pnpm in dev mode
 
62
  CMD ["pnpm", "run", "dev"]
63
 
 
1
  # --- Stage 1: Base Setup ---
2
 
3
+ # Use Node.js 20 slim version as the base image
4
+ FROM node:20-slim AS base
5
 
6
  # Set environment variables
7
  ENV NODE_ENV=development \
 
22
 
23
  # --- Copy and Chown Before Corepack ---
24
  # Copy package.json and pnpm lock file first
25
+ # IMPORTANT: Ensure package.json contains the "packageManager" field for reliability on HF
26
  COPY package.json pnpm-lock.yaml* ./
27
 
28
+ # Change ownership of the /app directory to the 'node' user early
29
+ # This ensures subsequent commands/copies have correct permissions
30
  RUN chown -R node:node /app
31
 
32
  # --- PNPM Activation ---
33
+ # Enable corepack (built into Node >=16.13 / Node 20 includes this) to manage pnpm
34
  RUN corepack enable
35
 
36
  # Verify pnpm is active and check its version (optional, for confirmation)
 
44
  # --- Stage 3: Build & Runtime Setup ---
45
 
46
  # Copy the rest of your application code
47
+ # Files will be owned by 'node' because of the earlier chown on /app
48
  COPY . .
49
 
50
+ # --- Removed Directory Creation for /app ---
51
+ # DO NOT create session/downloads/auth_info_baileys here.
52
+ # Your application code should write persistent data to the /data directory,
53
+ # which requires enabling Persistent Storage in Hugging Face Space settings.
 
 
54
 
55
+ # Switch to the non-root 'node' user (security best practice)
56
  USER node
57
 
58
+ # Expose the port your application will run on
59
  EXPOSE 7860
60
 
61
  # The command to run your application using pnpm in dev mode
62
+ # Consider using "pnpm run start" if you don't need --watch in deployment
63
  CMD ["pnpm", "run", "dev"]
64