diff --git a/.dockerignore b/.dockerignore index b64ddbc..5ea6f8d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,6 @@ -lib venv +libs/rpi-rgb-led-matrix/fonts +libs/rpi-rgb-led-matrix/images +libs/rpi-rgb-led-matrix/bindings/python/build +images/backgrounds/* +images/weather/* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ea6ec29..474abc6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,29 @@ -FROM python:3.10 +ARG base_image="python" +ARG base_tag="3.10" +ARG uid="1000" -COPY . /app +FROM ${base_image}:${base_tag} AS build +ARG uid + +COPY ./pyproject.toml ./poetry.lock /app/ WORKDIR /app RUN python -m venv /venv && \ - python -m pip install --upgrade pip poetry && \ - poetry install + /venv/bin/python -m pip install --upgrade pip poetry +RUN . /venv/bin/activate && poetry install + +COPY . /app +RUN . /venv/bin/activate && ls /app && cd /app/lib/rpi-rgb-led-matrix && make build-python + +RUN chown -R ${uid} /app + +FROM ${base_image}:${base_tag} AS runtime +ARG uid + +COPY --from=build /venv /venv +COPY --from=build /app /app + +WORKDIR /app +USER ${uid} +CMD ["/venv/bin/python", "-m", "wideboy"] \ No newline at end of file