Spaces:
Building
Building
# --- Stage 1: Base Setup --- | |
# Use Node.js 22 slim version as the base image | |
FROM node:22-slim AS base | |
# Set environment variables | |
ENV NODE_ENV=development \ | |
PNPM_HOME="/pnpm" \ | |
PATH="$PNPM_HOME:$PATH" | |
# Update package lists, install git and common build dependencies, and clean up | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends \ | |
git \ | |
python3 \ | |
make \ | |
g++ \ | |
&& rm -rf /var/lib/apt/lists/* | |
# --- PNPM Activation --- | |
# Enable corepack (built into Node >=16.13) to manage pnpm | |
# This makes the 'pnpm' command available without global install | |
RUN corepack enable | |
# Verify pnpm is active and check its version (optional, for confirmation) | |
RUN pnpm --version | |
# --- End PNPM Activation --- | |
# Set the working directory inside the container | |
WORKDIR /app | |
# --- Stage 2: Install Dependencies --- | |
# Copy package.json and pnpm lock file first to leverage Docker cache | |
COPY package.json pnpm-lock.yaml* ./ | |
# Install dependencies using pnpm. Requires pnpm to be active (done above). | |
RUN pnpm install --frozen-lockfile | |
# --- Stage 3: Build & Runtime Setup --- | |
# Copy the rest of your application code | |
COPY . . | |
# Create the directories as requested and set permissions to 777 (Use with caution!) | |
# WARNING: chmod 777 is a potential security risk. Grants full access to everyone. | |
RUN mkdir -p ./session ./downloads ./auth_info_baileys && \ | |
chmod -R 777 ./session ./downloads ./auth_info_baileys | |
# Switch to the non-root 'node' user (still recommended for running the process) | |
USER node | |
# Expose the port your application will run on (as requested) | |
EXPOSE 7860 | |
# The command to run your application using pnpm in dev mode | |
CMD ["pnpm", "run", "dev"] | |