Spaces:
Paused
Paused
Create Dockerfile
Browse files- Dockerfile +58 -0
Dockerfile
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use Node.js 20 Alpine version as the base image (lightweight but check compatibility)
|
| 2 |
+
FROM node:20-alpine
|
| 3 |
+
|
| 4 |
+
# Set environment variables
|
| 5 |
+
ENV NODE_ENV=development \
|
| 6 |
+
PNPM_HOME="/pnpm" \
|
| 7 |
+
PATH="$PNPM_HOME:$PATH"
|
| 8 |
+
|
| 9 |
+
# Install prerequisites using apk (Alpine package manager)
|
| 10 |
+
# Add git, python3, make, g++ (build-base provides make/g++)
|
| 11 |
+
RUN apk add --no-cache \
|
| 12 |
+
git \
|
| 13 |
+
python3 \
|
| 14 |
+
build-base
|
| 15 |
+
|
| 16 |
+
# Install pnpm globally using npm (common method on Alpine)
|
| 17 |
+
# Consider matching the version from your package.json "packageManager" field if added
|
| 18 |
+
RUN npm install -g pnpm
|
| 19 |
+
|
| 20 |
+
# Verify pnpm installation
|
| 21 |
+
RUN pnpm --version
|
| 22 |
+
|
| 23 |
+
# Set the working directory
|
| 24 |
+
WORKDIR /app
|
| 25 |
+
|
| 26 |
+
# Copy package manifests
|
| 27 |
+
# IMPORTANT: Ensure package.json contains the "packageManager" field for reliability
|
| 28 |
+
COPY package.json pnpm-lock.yaml* ./
|
| 29 |
+
|
| 30 |
+
# Install ALL dependencies using pnpm (needed for devDependencies like vite-node)
|
| 31 |
+
RUN pnpm install --frozen-lockfile
|
| 32 |
+
|
| 33 |
+
# Copy the rest of your application code
|
| 34 |
+
COPY . .
|
| 35 |
+
|
| 36 |
+
# --- Create Non-Root User for Alpine ---
|
| 37 |
+
# Alpine images don't have a 'node' user by default like Debian ones
|
| 38 |
+
# Create a non-root user and group (-S for system user/group)
|
| 39 |
+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
| 40 |
+
|
| 41 |
+
# Change ownership of the app directory to the new user
|
| 42 |
+
RUN chown -R appuser:appgroup /app
|
| 43 |
+
# --- End User Creation ---
|
| 44 |
+
|
| 45 |
+
# --- Removed Directory Creation for /app ---
|
| 46 |
+
# DO NOT create session/downloads/auth_info_baileys here.
|
| 47 |
+
# Your application code should write persistent data to the /data directory,
|
| 48 |
+
# which requires enabling Persistent Storage in Hugging Face Space settings.
|
| 49 |
+
|
| 50 |
+
# Switch to the non-root user
|
| 51 |
+
USER appuser
|
| 52 |
+
|
| 53 |
+
# Expose the port your application listens on
|
| 54 |
+
EXPOSE 7860
|
| 55 |
+
|
| 56 |
+
# The command to run your application using pnpm in dev mode
|
| 57 |
+
CMD ["pnpm", "run", "dev"]
|
| 58 |
+
|