Spaces:
Building
Building
Update Dockerfile
Browse files- Dockerfile +14 -13
Dockerfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
# --- Stage 1: Base Setup ---
|
2 |
|
3 |
-
# Use Node.js
|
4 |
-
FROM node:
|
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
|
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 |
-
# ---
|
49 |
-
#
|
50 |
-
#
|
51 |
-
|
52 |
-
chmod -R 777 ./session ./downloads ./auth_info_baileys
|
53 |
-
# --- END OF MODIFIED SECTION ---
|
54 |
|
55 |
-
# Switch to the non-root 'node' user (
|
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 |
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 |
|