Spaces:
Sleeping
Sleeping
File size: 1,318 Bytes
e86a6ff a6b0c55 3149b7e e86a6ff 3149b7e e86a6ff a6b0c55 e86a6ff a6b0c55 4e44943 | 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 | FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
RUN useradd --create-home appuser
# Install dependencies in a cached layer that only invalidates when
# pyproject.toml changes. The dep list is extracted from pyproject.toml at
# build time so there's no duplication between the two files.
COPY pyproject.toml README.md /app/
RUN pip install --no-cache-dir --upgrade pip && \
python -c "import tomllib; print('\n'.join(tomllib.load(open('pyproject.toml', 'rb'))['project']['dependencies']))" > /tmp/requirements.txt && \
pip install --no-cache-dir -r /tmp/requirements.txt && \
rm /tmp/requirements.txt
# Copy the full source tree and register the project itself. --no-deps is
# safe because the deps layer above has already resolved everything, and it
# keeps this layer fast: editing a single source file re-runs a few-second
# package registration instead of a multi-minute dependency solve.
COPY . /app
RUN pip install --no-cache-dir --no-deps .
RUN chown -R appuser:appuser /app
USER appuser
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
CMD ["uvicorn", "chargeback_ops.server.app:app", "--host", "0.0.0.0", "--port", "8000"]
|