-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
63 lines (44 loc) · 1.6 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
61
62
63
# syntax=docker/dockerfile:1
FROM python:3.12-bookworm as builder
# Install Poetry
RUN pip install poetry==1.4.2
# Configure Poetry to use virtual environment in the project directory
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
WORKDIR /app
# Copy over the dependencies
COPY pyproject.toml poetry.lock README.md ./
# And install those dependencies
RUN poetry install -E uvloop --without dev --no-root && rm -rf $POETRY_CACHE_DIR
FROM python:3.12-slim-bookworm as runtime
LABEL org.opencontainers.image.source=https://github.com/JustAnyones/Pidroid
LABEL org.opencontainers.image.description="Pidroid Discord bot for TheoTown"
LABEL org.opencontainers.image.licenses=MIT
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
# Install libopus and ffmpeg
RUN apt-get update
RUN apt-get install libopus-dev -y --no-install-recommends
RUN rm -rf /var/lib/apt/lists/*
COPY --from=mwader/static-ffmpeg:7.1 /ffmpeg /usr/local/bin/
# Create Pidroid user account
RUN groupadd -g 999 pidroid
RUN useradd -r -u 999 -g pidroid pidroid
# Copy dependencies from builder
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
# Copy over alembic migration files
COPY alembic/ /app/alembic/
COPY alembic.ini /app/alembic.ini
# Copy over the project files
COPY pidroid /app/pidroid
COPY pyproject.toml poetry.lock README.md /app/
# Set git commit
ARG GIT_COMMIT
ENV GIT_COMMIT=$GIT_COMMIT
WORKDIR /app
# Install Pidroid package
RUN pip install .
# Perform migrations and run Pidroid
CMD alembic upgrade head && python -m pidroid.main