-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
35 lines (26 loc) · 1006 Bytes
/
Dockerfile
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
# syntax=docker/dockerfile:1.3
FROM python:3.12-slim as base
WORKDIR /app
FROM base as builder
RUN apt-get update \
&& apt-get install -y git \
&& rm -rf /var/lib/apt/lists/*
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
RUN --mount=type=cache,target=/root/.cache/pip \
pip install git+https://github.com/python-poetry/poetry.git@625f42ef96f8321f4e1649f38e39e71cd2b09f3e \
&& pip install poetry-plugin-export
RUN python -m venv /venv
COPY pyproject.toml poetry.lock LICENSE ./
RUN --mount=type=cache,target=/root/.cache/pip \
poetry export -o /tmp/requirements.txt && /venv/bin/pip install -r /tmp/requirements.txt
COPY . .
RUN sed -i "s/\(COMMIT_HASH *= *\).*/\1'$(git rev-parse HEAD)'/" tgpy/version.py
RUN rm -rf .git guide poetry.lock pyproject.toml .dockerignore .gitignore README.md
FROM base as runner
COPY --from=builder /venv /venv
ENV PATH="/venv/bin:$PATH"
COPY --from=builder /app /app
ENV TGPY_DATA=/data
ENV PYTHONPATH=/app
VOLUME /data
ENTRYPOINT ["/app/entrypoint.sh"]