-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
60 lines (39 loc) · 1.52 KB
/
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
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
# syntax=docker.io/docker/dockerfile:1.5
ARG PYTHON_VERSION=3.11
FROM docker.io/python:${PYTHON_VERSION}-slim-bookworm as build
WORKDIR /app
# NOTE: we use a special cache mount for the pip cache
# hadolint ignore=DL3042
RUN --mount=type=cache,target=~/.cache,id=pip-cache-poetry-install \
pip install "poetry==1.4.2"
COPY --chown=nonroot:nonroot pyproject.toml poetry.* ./
# NOTE: add poetry to path
ARG PATH="$PATH:~/.local/bin"
ARG POETRY_NO_INTERACTION=true
ARG POETRY_VIRTUALENVS_OPTIONS_NO_SETUPTOOLS=true
ARG POETRY_VIRTUALENVS_OPTIONS_NO_PIP=true
ARG POETRY_VIRTUALENVS_OPTIONS_ALWAYS_COPY=true
# FIXME: figure out why cache is not working
RUN --mount=type=cache,target=~/.cache,id=poetry-install \
poetry install --sync --no-root --only main \
&& rm -rf .venv/pyvenv.cfg .venv/src .venv/.gitignore
FROM docker.io/python:${PYTHON_VERSION}-slim-bookworm as base
WORKDIR /app
COPY --chown=nonroot:nonroot --from=build /app/.venv /app/.venv
COPY --chown=nonroot:nonroot dht_torznab dht_torznab
COPY --chown=nonroot:nonroot gunicorn.conf.py alembic.ini ./
# TODO: figure out why adding PYTHONPATH is necessary
ENV PYTHONUNBUFFERED=1 \
PATH="/app/.venv/bin:$PATH" \
PYTHONPATH="/app/.venv/lib/python3.11/site-packages"
ENTRYPOINT [ "python" ]
FROM base as listener
CMD [ "-m", "dht_torznab.listener" ]
FROM base as peer_count_updater
CMD [ "-m", "dht_torznab.peer_count_updater" ]
FROM base as api
ENTRYPOINT [ "gunicorn" ]
EXPOSE 8080/tcp
FROM base as migrations
ENTRYPOINT [ "alembic" ]
CMD [ "upgrade", "head" ]