forked from ApexChainx/ApexChainx-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (25 loc) · 1.02 KB
/
Copy pathDockerfile
File metadata and controls
36 lines (25 loc) · 1.02 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
FROM python:3.11-slim-bookworm AS builder
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
build-essential \
libpq-dev && \
rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt && \
pip install --user --no-cache-dir gunicorn
FROM python:3.11-slim-bookworm AS runtime
RUN groupadd -r appuser && \
useradd -r -g appuser -d /app -s /sbin/nologin -u 1000 appuser
COPY --from=builder /root/.local /home/appuser/.local
ENV \
PATH=/home/appuser/.local/bin:$PATH \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
WORKDIR /app
COPY --chown=appuser:appuser . .
USER appuser
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD python -c "import urllib.request, sys; sys.exit(0 if urllib.request.urlopen('http://localhost:8000/health/liveness').status == 200 else 1)"
CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "-w", "4", "--bind", "0.0.0.0:8000", "main:app"]