40 lines
870 B
Docker
40 lines
870 B
Docker
ARG PYTHON_VERSION=3.10
|
|
FROM python:${PYTHON_VERSION}-slim
|
|
|
|
# avoid .pyc and buffering stdout/stderr
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# add non-root user
|
|
ARG UID=1000
|
|
RUN adduser \
|
|
--disabled-password \
|
|
--no-create-home \
|
|
--uid "${UID}" \
|
|
--home "/app" \
|
|
bot
|
|
|
|
# install requirements
|
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
|
--mount=type=bind,source=requirements.txt,target=requirements.txt \
|
|
pip install -r requirements.txt
|
|
|
|
# copy sources
|
|
COPY --chown=bot --chmod=774 docker-entrypoint.sh /app/
|
|
COPY --chown=bot migrations /app/migrations
|
|
COPY --chown=bot mybot /app/mybot
|
|
COPY --chown=bot i18n.yaml /app/
|
|
|
|
# prepare environment
|
|
ENV I18N_PATH=/data/i18n.yaml
|
|
ENV DB_URL=sqlite:////data/bot.db
|
|
|
|
RUN mkdir -p /data
|
|
RUN chown bot:bot /data
|
|
VOLUME /data
|
|
|
|
USER bot
|
|
WORKDIR /app
|
|
|
|
ENTRYPOINT ["./docker-entrypoint.sh"]
|