-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
80 lines (64 loc) · 1.76 KB
/
Dockerfile
File metadata and controls
80 lines (64 loc) · 1.76 KB
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
# Stage 1: Base image with Node.js
FROM node:20 AS base
# Install required system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
python3-pip \
build-essential \
tesseract-ocr \
tesseract-ocr-eng \
tesseract-ocr-fra \
tesseract-ocr-deu \
tesseract-ocr-spa \
ghostscript \
unpaper \
pngquant \
qpdf \
libleptonica-dev \
liblept5 \
libffi-dev \
libsm6 \
libxext6 \
libxrender-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Stage 2: Dependencies
FROM base AS deps
WORKDIR /app
# Copy package files
COPY package.json package-lock.json ./
# Install dependencies with legacy peer deps to handle compatibility issues
RUN npm install --legacy-peer-deps
# Stage 3: Builder
FROM deps AS builder
WORKDIR /app
# Copy source files
COPY . .
# Set environment for build
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
# Build application with legacy peer deps
RUN npm run build
# Stage 4: Runner
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
# Create app directory structure
RUN mkdir -p /app/processed /app/uploads /app/output /app/tmp \
&& chown -R node:node /app
# Copy built application
COPY --from=builder --chown=node:node /app/public ./public
COPY --from=builder --chown=node:node /app/.next ./.next
COPY --from=builder --chown=node:node /app/node_modules ./node_modules
COPY --from=builder --chown=node:node /app/package.json ./package.json
COPY --from=builder --chown=node:node /app/next.config.mjs ./next.config.mjs
# Set up volumes
VOLUME ["/app/processed", "/app/uploads", "/app/output"]
# Switch to non-root user
USER node
# Expose port
EXPOSE 3000
# Start the application
CMD ["npm", "start"]