Spaces:
Building
Building
Create Dockerfile
Browse files- Dockerfile +58 -0
Dockerfile
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 \
|
8 |
+
PNPM_HOME="/pnpm" \
|
9 |
+
PATH="$PNPM_HOME:$PATH"
|
10 |
+
|
11 |
+
# Update package lists, install git and common build dependencies, and clean up
|
12 |
+
RUN apt-get update && \
|
13 |
+
apt-get install -y --no-install-recommends \
|
14 |
+
git \
|
15 |
+
python3 \
|
16 |
+
make \
|
17 |
+
g++ \
|
18 |
+
&& rm -rf /var/lib/apt/lists/*
|
19 |
+
|
20 |
+
# --- PNPM Activation ---
|
21 |
+
# Enable corepack (built into Node >=16.13) to manage pnpm
|
22 |
+
# This makes the 'pnpm' command available without global install
|
23 |
+
RUN corepack enable
|
24 |
+
|
25 |
+
# Verify pnpm is active and check its version (optional, for confirmation)
|
26 |
+
RUN pnpm --version
|
27 |
+
# --- End PNPM Activation ---
|
28 |
+
|
29 |
+
# Set the working directory inside the container
|
30 |
+
WORKDIR /app
|
31 |
+
|
32 |
+
# --- Stage 2: Install Dependencies ---
|
33 |
+
|
34 |
+
# Copy package.json and pnpm lock file first to leverage Docker cache
|
35 |
+
COPY package.json pnpm-lock.yaml* ./
|
36 |
+
|
37 |
+
# Install dependencies using pnpm. Requires pnpm to be active (done above).
|
38 |
+
RUN pnpm install --frozen-lockfile
|
39 |
+
|
40 |
+
# --- Stage 3: Build & Runtime Setup ---
|
41 |
+
|
42 |
+
# Copy the rest of your application code
|
43 |
+
COPY . .
|
44 |
+
|
45 |
+
# Create the directories as requested and set permissions to 777 (Use with caution!)
|
46 |
+
# WARNING: chmod 777 is a potential security risk. Grants full access to everyone.
|
47 |
+
RUN mkdir -p ./session ./downloads ./auth_info_baileys && \
|
48 |
+
chmod -R 777 ./session ./downloads ./auth_info_baileys
|
49 |
+
|
50 |
+
# Switch to the non-root 'node' user (still recommended for running the process)
|
51 |
+
USER node
|
52 |
+
|
53 |
+
# Expose the port your application will run on (as requested)
|
54 |
+
EXPOSE 7860
|
55 |
+
|
56 |
+
# The command to run your application using pnpm in dev mode
|
57 |
+
CMD ["pnpm", "run", "dev"]
|
58 |
+
|