-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.api
More file actions
41 lines (33 loc) · 1.29 KB
/
Dockerfile.api
File metadata and controls
41 lines (33 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
FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Add deadsnakes PPA for Python 3.12 (Ubuntu 22.04 only ships 3.10)
RUN apt-get update && apt-get install -y --no-install-recommends software-properties-common gpg-agent \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update && apt-get install -y --no-install-recommends \
python3.12 \
python3.12-venv \
python3.12-dev \
curl \
build-essential \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Use python3.12 as default
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1
WORKDIR /app
ENV PYTHONPATH=/app
# Bootstrap pip for Python 3.12
RUN python -m ensurepip --upgrade
# Copy all application code
COPY pyproject.toml .
COPY src/ src/
COPY alembic/ alembic/
COPY alembic.ini .
# Install Python dependencies (editable install needs src/ present)
RUN python -m pip install --no-cache-dir --upgrade pip \
&& python -m pip install --no-cache-dir -e ".[gpu]"
# Run DB migrations on startup, then launch API
EXPOSE 8000
CMD ["sh", "-c", "python -m alembic upgrade head && uvicorn src.api.main:app --host 0.0.0.0 --port 8000"]