Spaces:
Building
Building
File size: 1,790 Bytes
ae39c21 008b10c ae39c21 008b10c ae39c21 7a67f1d ae39c21 7a67f1d ae39c21 7a67f1d ae39c21 008b10c ae39c21 008b10c ae39c21 008b10c ae39c21 a8498e2 008b10c ae39c21 008b10c ae39c21 008b10c |
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 58 59 |
# 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"]
|