# Use Node.js 20 Alpine version as the base image (lightweight but check compatibility) 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) # Consider matching the version from your package.json "packageManager" field if added RUN npm install -g pnpm # 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 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 Non-Root User for Alpine --- # Alpine images don't have a 'node' user by default like Debian ones # Create a non-root user and group (-S for system user/group) RUN addgroup -S appgroup && adduser -S appuser -G appgroup # Change ownership of the app directory to the new user RUN chown -R appuser:appgroup /app # --- End User Creation --- # --- Removed Directory Creation for /app --- # DO NOT create session/downloads/auth_info_baileys here. # Your application code should write persistent data to the /data directory, # which requires enabling Persistent Storage in Hugging Face Space settings. # Switch to the non-root user USER appuser # Expose the port your application listens on EXPOSE 7860 # The command to run your application using pnpm in dev mode CMD ["pnpm", "run", "dev"]