-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile.dev
69 lines (51 loc) · 1.7 KB
/
Dockerfile.dev
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Build stage
FROM python:3.13.1-slim as builder
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=utf-8 \
DEBIAN_FRONTEND=noninteractive \
POETRY_VERSION=1.7.1 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_CREATE=false
WORKDIR /src
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Install poetry
RUN curl -sSL https://install.python-poetry.org | python3 - && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry
# Install dependencies
COPY pyproject.toml poetry.lock* ./
RUN poetry install --no-root --no-interaction --no-ansi
# Runtime stage
FROM python:3.13.1-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=utf-8
WORKDIR /src
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
gettext \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN adduser --disabled-password --gecos "" tgbot_app
# Copy dependencies from builder
COPY --from=builder /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages
COPY --from=builder /usr/local/bin/pybabel* /usr/local/bin/
# Copy application
COPY ./scripts /src/scripts
RUN chmod +x /src/scripts/*
COPY ./app /src/app
COPY ./run_polling.py /src/run_polling.py
RUN pybabel compile -d /src/app/locales -D messages
RUN mkdir -p /src/logs && \
chown -R tgbot_app:tgbot_app /src && \
chmod -R 755 /src && \
chmod 777 /src/logs
USER tgbot_app
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
ENTRYPOINT ["sh", "/src/scripts/docker-entrypoint.dev.sh"]