-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (46 loc) · 1.29 KB
/
Dockerfile
File metadata and controls
59 lines (46 loc) · 1.29 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
# Multi-stage build for optimized production image
FROM node:18-alpine AS frontend-builder
# Build frontend
WORKDIR /app/frontend
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
# Python backend
FROM python:3.11-slim AS backend
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Install Python dependencies
COPY requirements.txt .
COPY api/requirements.txt ./api/
RUN pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir -r api/requirements.txt
# Copy backend code
COPY src/ ./src/
COPY api/ ./api/
COPY config/ ./config/
COPY scripts/ ./scripts/
COPY *.py ./
# Copy frontend build
COPY --from=frontend-builder /app/frontend/dist ./static
# Create non-root user
RUN useradd -m -u 1000 canairy && \
chown -R canairy:canairy /app
USER canairy
# Environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PORT=8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${PORT}/health || exit 1
# Expose port
EXPOSE ${PORT}
# Start application
CMD ["python", "-m", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000"]