pping / Dockerfile
understanding's picture
Update Dockerfile
8e2e0bd verified
# Use Node.js 20 Alpine version as the base image
FROM node:20-alpine
# Set environment variables
ENV NODE_ENV=development \
PNPM_HOME="/pnpm" \
PATH="$PNPM_HOME:$PATH"
# Install prerequisites using apk (Alpine package manager)
# Add git, python3, make, g++ (build-base provides make/g++)
RUN apk add --no-cache \
git \
python3 \
build-base
# Install pnpm globally using npm (common method on Alpine)
RUN npm install -g pnpm --loglevel error # Added --loglevel error to reduce npm noise
# Verify pnpm installation
RUN pnpm --version
# Set the working directory
WORKDIR /app
# Copy package manifests
# IMPORTANT: Ensure package.json contains the "packageManager" field for reliability
COPY package*.json ./
COPY pnpm-lock.yaml* ./
# Install ALL dependencies using pnpm (needed for devDependencies like vite-node)
RUN pnpm install --frozen-lockfile
# Copy the rest of your application code
COPY . .
# Create directories and set wide-open permissions (as requested in example)
# WARNING: chmod 777 is a potential security risk.
# WARNING: Data in these /app directories WILL NOT PERSIST on Hugging Face Spaces restarts!
RUN mkdir -p ./session ./downloads ./auth_info_baileys && \
chmod -R 777 ./session ./downloads ./auth_info_baileys
# --- Create Non-Root User for Alpine ---
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Change ownership of the app directory AFTER copying all code and creating subdirs
RUN chown -R appuser:appgroup /app
# --- End User Creation ---
# Switch to the non-root user
USER appuser
# Expose the port your application listens on (assuming 7860)
EXPOSE 7860
# The command to run your application using pnpm in dev mode (matches package.json script)
CMD ["pnpm", "run", "dev"]