Skip to content

Commit

Permalink
Dockerfile: best practices & prep for supercronic usage
Browse files Browse the repository at this point in the history
  • Loading branch information
stynoo committed Dec 15, 2024
1 parent 30247bc commit 5f30683
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
FROM python:3.12-alpine

RUN adduser -D withings-sync
ENV PROJECT=withings-sync
ENV PACKAGE=withings_sync
ENV PROJECT_DIR=/home/$PROJECT

USER withings-sync
WORKDIR /home/withings-sync
RUN apk --no-cache add supercronic

ENV PATH="/home/withings-sync/.poetry/bin:${PATH}" \
PATH="/home/withings-sync/.local/bin:${PATH}" \
RUN adduser -D $PROJECT

USER $PROJECT
WORKDIR $PROJECT_DIR

ENV PATH="${PROJECT_DIR}/.poetry/bin:${PATH}" \
PATH="${PROJECT_DIR}/.local/bin:${PATH}" \
PIP_ROOT_USER_ACTION=ignore \
PIP_DISABLE_PIP_VERSION_CHECK=on \
POETRY_HOME=/home/withings-sync/.poetry \
POETRY_HOME="${PROJECT_DIR}/.poetry" \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
POETRY_CACHE_DIR="/tmp/poetry_cache"

RUN pip install poetry

COPY --chown=withings-sync:withings-sync pyproject.toml poetry.lock README.md ./
COPY --chown=$PROJECT:$PROJECT pyproject.toml poetry.lock README.md $PROJECT_DIR/
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR

COPY --chown=withings-sync:withings-sync withings_sync ./withings_sync/
COPY --chown=$PROJECT:$PROJECT $PACKAGE ./$PACKAGE/
RUN poetry install --without dev

ENTRYPOINT ["poetry", "run", "withings-sync"]

0 comments on commit 5f30683

Please sign in to comment.