-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile.webapp
More file actions
57 lines (42 loc) · 1.54 KB
/
Dockerfile.webapp
File metadata and controls
57 lines (42 loc) · 1.54 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
# --- Builder Stage ---
FROM python:3.12-slim-bookworm AS builder
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
WORKDIR /app
# Configure uv to install to system location
ENV UV_PROJECT_ENVIRONMENT="/usr/local"
ENV UV_COMPILE_BYTECODE=1
# Step 1: Copy only dependency files (cached layer)
COPY pyproject.toml uv.lock ./
COPY bot/pyproject.toml ./bot/
COPY shared/pyproject.toml ./shared/
COPY webapp/pyproject.toml ./webapp/
# Create minimal package structure for uv workspace resolution
RUN mkdir -p bot/other shared/src/shared webapp && \
touch bot/__init__.py bot/other/__init__.py && \
touch shared/src/shared/__init__.py && \
touch webapp/__init__.py
# Step 2: Install dependencies (cached unless pyproject.toml/uv.lock change)
RUN uv sync --frozen --no-dev --package mmwb-webapp
# Step 3: Copy actual source code (invalidates only on code changes)
COPY bot ./bot
COPY shared ./shared
COPY webapp ./webapp
# --- Final Stage ---
FROM python:3.12-slim-bookworm
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Copy installed python packages from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Copy application code
COPY shared ./shared
COPY webapp ./webapp
# Expose port
EXPOSE 8000
# Git commit (at the end to not break cache)
ARG GIT_COMMIT=unknown
LABEL org.opencontainers.image.revision="${GIT_COMMIT}"
ENV GIT_COMMIT=${GIT_COMMIT}
# Run uvicorn
CMD ["uvicorn", "webapp.app:app", "--host", "0.0.0.0", "--port", "8000"]