-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (41 loc) · 1.39 KB
/
Dockerfile
File metadata and controls
58 lines (41 loc) · 1.39 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
# Stage 1: Build frontend
FROM node:20-alpine AS frontend-build
# Version ARG busts cache when version changes
ARG APP_VERSION=dev
WORKDIR /app/frontend
# Install dependencies
COPY frontend/package.json ./
RUN npm install
# Build production bundle (version baked in via vite.config.ts)
COPY frontend/ ./
RUN echo "Building version: $APP_VERSION" && npm run build
# Stage 2: Runtime
FROM python:3.12-slim AS runtime
# Install nginx, supervisor, and curl for healthcheck
RUN apt-get update && apt-get install -y --no-install-recommends \
nginx \
supervisor \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python dependencies
COPY backend/pyproject.toml ./
RUN pip install --no-cache-dir . && \
pip install --no-cache-dir uvicorn[standard]
# Copy backend code
COPY backend/app ./app
# Copy frontend build
COPY --from=frontend-build /app/frontend/dist /usr/share/nginx/html
# Copy nginx config
COPY deploy/nginx.conf /etc/nginx/nginx.conf
# Copy supervisor config
COPY deploy/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Create data directory
RUN mkdir -p /data && chown -R www-data:www-data /data
# Expose port
EXPOSE 80
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost/api/health || exit 1
# Run supervisor
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]