-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathDockerfile
More file actions
127 lines (100 loc) · 3.41 KB
/
Dockerfile
File metadata and controls
127 lines (100 loc) · 3.41 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Resume Matcher Docker Image
# Multi-stage build for optimized image size
# ============================================
# Stage 1: Build Frontend
# ============================================
FROM node:22-bookworm AS frontend-builder
# Build argument for API URL (allows customization at build time)
# Default routes requests through Next.js rewrites on the same origin.
ARG NEXT_PUBLIC_API_URL=/
ENV NEXT_TELEMETRY_DISABLED=1 \
NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
WORKDIR /app/frontend
# Copy package files first for better caching
COPY apps/frontend/package*.json ./
# Install dependencies
RUN npm ci
# Copy frontend source
COPY apps/frontend/ ./
# Build the frontend
RUN npm run build
# ============================================
# Stage 2: Final Image
# ============================================
FROM python:3.13-slim-bookworm
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
# Playwright dependencies
libnss3 \
libnspr4 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libxkbcommon0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libasound2 \
libpango-1.0-0 \
libcairo2 \
libatspi2.0-0 \
libgtk-3-0 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy Node.js runtime from frontend builder for reproducible runtime behavior.
COPY --from=frontend-builder /usr/local/bin/node /usr/local/bin/node
# ============================================
# Backend Setup
# ============================================
COPY apps/backend/pyproject.toml /app/backend/
COPY apps/backend/app /app/backend/app
WORKDIR /app/backend
# Install Python dependencies
RUN pip install .
# ============================================
# Frontend Setup
# ============================================
WORKDIR /app/frontend
# Copy standalone frontend runtime from builder stage
COPY --from=frontend-builder /app/frontend/.next/standalone ./
COPY --from=frontend-builder /app/frontend/.next/static ./.next/static
COPY --from=frontend-builder /app/frontend/public ./public
# ============================================
# Startup Script
# ============================================
COPY docker/start.sh /app/start.sh
# Convert CRLF to LF (fixes Windows line ending issues) and make executable
RUN sed -i 's/\r$//' /app/start.sh && chmod +x /app/start.sh
# ============================================
# Data Directory & Volume
# ============================================
RUN mkdir -p /app/backend/data
# Create a non-root user for security
RUN useradd -m -u 1000 appuser \
&& chown -R appuser:appuser /app
USER appuser
# Install Playwright Chromium as appuser (so browsers are in correct location)
RUN python -m playwright install chromium
# Expose the public port (backend remains internal on 8000)
EXPOSE 3000
# Volume for persistent data
VOLUME ["/app/backend/data"]
# Set working directory
WORKDIR /app
# Health check on internal backend port only (independent of host port mapping).
HEALTHCHECK --interval=10s --timeout=10s --start-period=30s --retries=5 \
CMD curl -f http://127.0.0.1:8000/api/v1/health || exit 1
# Start the application
CMD ["/app/start.sh"]