-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (52 loc) · 1.87 KB
/
Dockerfile
File metadata and controls
71 lines (52 loc) · 1.87 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
# Multi-stage build for single-container deployment
FROM node:20-slim AS frontend-builder
WORKDIR /app/frontend
# Build metadata (forwarded to Vite)
ARG APP_VERSION=dev
ENV VITE_APP_VERSION=$APP_VERSION
# Copy only dependency files first for better layer caching
COPY package*.json ./
# Install dependencies (this layer will be cached unless package.json changes)
# Use BuildKit cache mount for npm cache (faster subsequent builds)
RUN --mount=type=cache,target=/root/.npm \
npm ci --legacy-peer-deps || npm install --legacy-peer-deps
# Copy config files needed for build
COPY vite.config.ts tsconfig*.json ./
COPY tailwind.config.ts postcss.config.js ./
COPY index.html ./
# Copy source files (these change frequently, so copy after dependencies)
COPY src ./src
COPY public ./public
# Build frontend in production mode
ENV NODE_ENV=production
RUN npm run build
# Backend stage
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:$PATH"
# Copy backend dependency files
COPY backend/pyproject.toml backend/requirements.txt ./
RUN uv pip install --system --no-cache -r requirements.txt
# Copy backend code (including Alembic migrations)
COPY backend ./backend
# Copy built frontend from builder stage
COPY --from=frontend-builder /app/frontend/dist ./frontend_dist
# Create data directory for SQLite
RUN mkdir -p /app/data
# Copy and make entrypoint script executable
COPY backend/entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
# Set PYTHONPATH to include backend directory so imports work correctly
ENV PYTHONPATH="/app/backend"
# Expose port
EXPOSE 8000
# Use entrypoint script to run migrations then start the app
ENTRYPOINT ["/app/entrypoint.sh"]