-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (39 loc) · 1.33 KB
/
Dockerfile
File metadata and controls
55 lines (39 loc) · 1.33 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
FROM python:3.11-slim AS builder
WORKDIR /build
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip wheel --no-cache-dir --wheel-dir /wheels -r requirements.txt
FROM python:3.11-slim
WORKDIR /app
COPY --from=builder /wheels /wheels
RUN pip install --no-cache-dir --no-index --find-links=/wheels /wheels/* && \
rm -rf /wheels && \
apt-get update && apt-get install -y --no-install-recommends gosu && \
apt-get purge -y --auto-remove && \
rm -rf /var/lib/apt/lists/*
COPY main.py ./
COPY config.py ./
COPY database.py ./
COPY db_models.py ./
COPY custom_types/ ./custom_types/
COPY middleware/ ./middleware/
COPY models/ ./models/
COPY routers/ ./routers/
COPY services/ ./services/
COPY templates/ ./templates/
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh && \
useradd -m -u 1000 appuser && \
chown -R appuser:appuser /app
USER appuser
EXPOSE 4323
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:4323/health').read()"
ENTRYPOINT ["/entrypoint.sh"]
CMD ["python", "-u", "main.py"]