You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.0 KiB
Docker
45 lines
1.0 KiB
Docker
# Build stage
|
|
FROM python:3.11-slim as builder
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
WORKDIR /build
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
libpq-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY requirements.txt .
|
|
RUN pip install --user --no-cache-dir -r requirements.txt
|
|
|
|
# Runtime stage
|
|
FROM python:3.11-slim
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PORT=8080
|
|
|
|
WORKDIR /app
|
|
|
|
# Install runtime dependencies only
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
libpq5 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy Python dependencies from builder
|
|
COPY --from=builder /root/.local /root/.local
|
|
|
|
# Copy application code
|
|
COPY app /app/app
|
|
|
|
ENV PATH=/root/.local/bin:$PATH
|
|
|
|
EXPOSE 8080
|
|
|
|
#HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
# CMD python -c "import httpx; httpx.get('http://localhost:8080/docs', timeout=5)" || exit 1
|
|
|
|
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8080}"]
|