File size: 1,712 Bytes
b0be643
 
 
 
 
 
 
989191e
b0be643
 
 
 
 
989191e
b0be643
 
989191e
b0be643
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
989191e
b0be643
 
 
 
 
 
 
 
 
 
989191e
 
b0be643
 
 
 
 
 
 
 
989191e
 
 
b0be643
 
 
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Build stage
FROM node:20-slim AS builder

# Set working directory
WORKDIR /app

# Copy package files
COPY cruciqe-id-card-backend/package*.json ./

# Install all dependencies (including dev dependencies for building)
RUN npm ci

# Copy TypeScript config
COPY cruciqe-id-card-backend/tsconfig.json ./

# Copy source files
COPY cruciqe-id-card-backend/src ./src

# Build TypeScript
RUN npm run build

# Production stage
FROM node:20-slim

# Install system dependencies for Puppeteer
RUN apt-get update && apt-get install -y \
    chromium \
    chromium-sandbox \
    fonts-liberation \
    libappindicator3-1 \
    libasound2 \
    libatk-bridge2.0-0 \
    libatk1.0-0 \
    libcups2 \
    libdbus-1-3 \
    libdrm2 \
    libgbm1 \
    libgtk-3-0 \
    libnspr4 \
    libnss3 \
    libx11-xcb1 \
    libxcomposite1 \
    libxdamage1 \
    libxfixes3 \
    libxrandr2 \
    xdg-utils \
    && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /app

# Copy package files
COPY cruciqe-id-card-backend/package*.json ./

# Install only production dependencies
RUN npm ci --only=production && npm cache clean --force

# Copy built files from builder stage
COPY --from=builder /app/dist ./dist

# Create directory for database and set permissions
RUN mkdir -p /app/data && chmod 777 /app/data

# Expose port 7860 (required for Hugging Face Spaces)
EXPOSE 7860

# Set working directory for database (persistent storage on HF spaces)
ENV DB_PATH=/app/data/dev.db

# Set environment variables for Puppeteer
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium

# Set port to 7860 (required for HF Spaces)
ENV PORT=7860

# Run the application
CMD ["node", "dist/index.js"]