|
1 | 1 | FROM python:3.12 |
2 | 2 |
|
3 | | -ARG API_USERNAME |
4 | | -ARG API_PASSWORD |
5 | | -ENV API_USERNAME ${API_USERNAME} |
6 | | -ENV API_PASSWORD ${API_PASSWORD} |
7 | | -ENV TIMEOUT=300 |
8 | | -# set api as the current work dir |
9 | | -WORKDIR /api |
10 | | - |
11 | | -# copy the requirements list |
12 | | -COPY requirements.txt requirements.txt |
13 | | - |
14 | | -# install all the requirements and import corpus |
15 | | -RUN pip install --no-cache-dir --upgrade -r requirements.txt && \ |
16 | | - python -m nltk.downloader stopwords |
17 | | - |
18 | | -# copy the main code of fastapi |
19 | | -COPY ./app /api/app |
20 | | - |
21 | | -# launch the unicorn server to run the api |
22 | | -# If you are running your container behind a TLS Termination Proxy (load balancer) like Nginx or Traefik, |
23 | | -# add the option --proxy-headers, this will tell Uvicorn to trust the headers sent by that proxy telling it |
24 | | -# that the application is running behind HTTPS, etc. |
25 | | -CMD ["uvicorn", "app.main:codification_ape_app", "--proxy-headers", "--host", "0.0.0.0", "--port", "80", "--timeout-graceful-shutdown", "300"] |
| 3 | +# Install system dependencies, including Git |
| 4 | +RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* |
| 5 | + |
| 6 | +# Set working directory inside `src/` |
| 7 | +WORKDIR /api/src |
| 8 | + |
| 9 | +# Copy pyproject.toml and lockfile for dependency resolution |
| 10 | +COPY pyproject.toml uv.lock ./ |
| 11 | + |
| 12 | +# Install uv package manager |
| 13 | +RUN pip install uv |
| 14 | + |
| 15 | +# Sync dependencies |
| 16 | +RUN uv sync |
| 17 | + |
| 18 | +# Copy application code |
| 19 | +COPY ./src /api/src |
| 20 | + |
| 21 | +# Expose port 5000 |
| 22 | +EXPOSE 5000 |
| 23 | + |
| 24 | +# Start FastAPI application |
| 25 | +CMD ["uv", "run", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "5000"] |
0 commit comments