Spaces:
Building
Building
File size: 1,759 Bytes
8e2e0bd de83751 8e2e0bd de83751 8e2e0bd de83751 8e2e0bd de83751 8e2e0bd de83751 8e2e0bd de83751 8e2e0bd de83751 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# 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"]
|