Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
!Containerfile*
!Dockerfile
!README.md
!LICENSE.md
!bin/container-entrypoint.sh
!examples/
!extra/
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/container-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
33 changes: 20 additions & 13 deletions Containerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,31 @@
ARG TARGET_VERSION="3.11-alpine"
ARG TARGET_ARCH="library"

FROM docker.io/${TARGET_ARCH}/python:${TARGET_VERSION}
FROM docker.io/${TARGET_ARCH}/python:${TARGET_VERSION} AS builder

WORKDIR /tmp/build

COPY . /tmp/build
COPY pyproject.toml poetry.lock /tmp/build/

RUN apk add --no-cache --virtual .build-deps build-base libffi-dev && \
pip install --no-cache-dir 'poetry==2.4.1' && \
poetry config virtualenvs.create false && \
poetry install --without dev --extras cli --extras tunnel --no-interaction --no-ansi --no-root

COPY . /tmp/build/

RUN poetry build --format wheel --no-interaction

RUN _poetry_venv_dir="$(mktemp -d -p "${TMPDIR:-/tmp}" 'poetry_venv.XXXXXX')" && \
apk add --no-cache libffi && \
apk add --no-cache --virtual .build-deps build-base libffi-dev && \
python -m 'venv' "${_poetry_venv_dir}" && \
"${_poetry_venv_dir}/bin/pip" install --no-cache-dir 'poetry' && \
"${_poetry_venv_dir}/bin/poetry" config --local virtualenvs.create false && \
"${_poetry_venv_dir}/bin/poetry" install --without dev --extras cli --extras tunnel --no-interaction --no-ansi && \
apk del .build-deps && \
FROM docker.io/${TARGET_ARCH}/python:${TARGET_VERSION}

RUN apk add --no-cache libffi && \
addgroup -S meshtastic && \
adduser -S -G meshtastic -h /home/meshtastic meshtastic && \
rm -f -r "${_poetry_venv_dir}" && \
rm -f -r "/tmp/build"
adduser -S -G meshtastic -h /home/meshtastic meshtastic

COPY --from=builder /tmp/build/dist/*.whl /tmp/

RUN wheel=$(echo /tmp/meshtastic-*.whl) && pip install --no-cache-dir "${wheel}[cli,tunnel]" && \
rm -f /tmp/meshtastic-*.whl

COPY "./bin/container-entrypoint.sh" "/init"
RUN chmod 0755 /init
Expand Down
28 changes: 18 additions & 10 deletions Containerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,28 @@
ARG TARGET_VERSION="3.11"
ARG TARGET_ARCH="library"

FROM docker.io/${TARGET_ARCH}/python:${TARGET_VERSION}
FROM docker.io/${TARGET_ARCH}/python:${TARGET_VERSION} AS builder

WORKDIR /tmp/build

COPY . /tmp/build
COPY pyproject.toml poetry.lock /tmp/build/

RUN pip install --no-cache-dir 'poetry==2.4.1' && \
poetry config virtualenvs.create false && \
poetry install --without dev --extras cli --extras tunnel --no-interaction --no-ansi --no-root

COPY . /tmp/build/

RUN poetry build --format wheel --no-interaction

FROM docker.io/${TARGET_ARCH}/python:${TARGET_VERSION}

RUN useradd --system --create-home --home-dir /home/meshtastic meshtastic

COPY --from=builder /tmp/build/dist/*.whl /tmp/

RUN _poetry_venv_dir="$(mktemp -d -p "${TMPDIR:-/tmp}" 'poetry_venv.XXXXXX')" && \
python -m 'venv' "${_poetry_venv_dir}" && \
"${_poetry_venv_dir}/bin/pip" install --no-cache-dir 'poetry' && \
"${_poetry_venv_dir}/bin/poetry" config --local virtualenvs.create false && \
"${_poetry_venv_dir}/bin/poetry" install --without dev --extras cli --extras tunnel --no-interaction --no-ansi && \
useradd --system --create-home --home-dir /home/meshtastic meshtastic && \
rm -f -r "${_poetry_venv_dir}" && \
rm -f -r "/tmp/build"
RUN wheel=$(echo /tmp/meshtastic-*.whl) && pip install --no-cache-dir "${wheel}[cli,tunnel]" && \
rm -f /tmp/meshtastic-*.whl

COPY "./bin/container-entrypoint.sh" "/init"
RUN chmod 0755 /init
Expand Down
Loading