understanding commited on
Commit
8e2e0bd
·
verified ·
1 Parent(s): 92a76c8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -16
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- # Use Node.js 20 Alpine version as the base image (lightweight but check compatibility)
2
  FROM node:20-alpine
3
 
4
  # Set environment variables
@@ -14,8 +14,7 @@ RUN apk add --no-cache \
14
  build-base
15
 
16
  # Install pnpm globally using npm (common method on Alpine)
17
- # Consider matching the version from your package.json "packageManager" field if added
18
- RUN npm install -g pnpm
19
 
20
  # Verify pnpm installation
21
  RUN pnpm --version
@@ -25,7 +24,8 @@ WORKDIR /app
25
 
26
  # Copy package manifests
27
  # IMPORTANT: Ensure package.json contains the "packageManager" field for reliability
28
- COPY package.json pnpm-lock.yaml* ./
 
29
 
30
  # Install ALL dependencies using pnpm (needed for devDependencies like vite-node)
31
  RUN pnpm install --frozen-lockfile
@@ -33,26 +33,24 @@ RUN pnpm install --frozen-lockfile
33
  # Copy the rest of your application code
34
  COPY . .
35
 
 
 
 
 
 
 
36
  # --- Create Non-Root User for Alpine ---
37
- # Alpine images don't have a 'node' user by default like Debian ones
38
- # Create a non-root user and group (-S for system user/group)
39
  RUN addgroup -S appgroup && adduser -S appuser -G appgroup
40
-
41
- # Change ownership of the app directory to the new user
42
  RUN chown -R appuser:appgroup /app
43
  # --- End User Creation ---
44
 
45
- # --- Removed Directory Creation for /app ---
46
- # DO NOT create session/downloads/auth_info_baileys here.
47
- # Your application code should write persistent data to the /data directory,
48
- # which requires enabling Persistent Storage in Hugging Face Space settings.
49
-
50
  # Switch to the non-root user
51
  USER appuser
52
 
53
- # Expose the port your application listens on
54
  EXPOSE 7860
55
 
56
- # The command to run your application using pnpm in dev mode
57
- CMD ["pnpm", "start"]
58
 
 
1
+ # Use Node.js 20 Alpine version as the base image
2
  FROM node:20-alpine
3
 
4
  # Set environment variables
 
14
  build-base
15
 
16
  # Install pnpm globally using npm (common method on Alpine)
17
+ RUN npm install -g pnpm --loglevel error # Added --loglevel error to reduce npm noise
 
18
 
19
  # Verify pnpm installation
20
  RUN pnpm --version
 
24
 
25
  # Copy package manifests
26
  # IMPORTANT: Ensure package.json contains the "packageManager" field for reliability
27
+ COPY package*.json ./
28
+ COPY pnpm-lock.yaml* ./
29
 
30
  # Install ALL dependencies using pnpm (needed for devDependencies like vite-node)
31
  RUN pnpm install --frozen-lockfile
 
33
  # Copy the rest of your application code
34
  COPY . .
35
 
36
+ # Create directories and set wide-open permissions (as requested in example)
37
+ # WARNING: chmod 777 is a potential security risk.
38
+ # WARNING: Data in these /app directories WILL NOT PERSIST on Hugging Face Spaces restarts!
39
+ RUN mkdir -p ./session ./downloads ./auth_info_baileys && \
40
+ chmod -R 777 ./session ./downloads ./auth_info_baileys
41
+
42
  # --- Create Non-Root User for Alpine ---
 
 
43
  RUN addgroup -S appgroup && adduser -S appuser -G appgroup
44
+ # Change ownership of the app directory AFTER copying all code and creating subdirs
 
45
  RUN chown -R appuser:appgroup /app
46
  # --- End User Creation ---
47
 
 
 
 
 
 
48
  # Switch to the non-root user
49
  USER appuser
50
 
51
+ # Expose the port your application listens on (assuming 7860)
52
  EXPOSE 7860
53
 
54
+ # The command to run your application using pnpm in dev mode (matches package.json script)
55
+ CMD ["pnpm", "run", "dev"]
56