|
5 | 5 | ARG TARGET_VERSION="3.11-alpine" |
6 | 6 | ARG TARGET_ARCH="library" |
7 | 7 |
|
8 | | -FROM docker.io/${TARGET_ARCH}/python:${TARGET_VERSION} |
| 8 | +FROM docker.io/${TARGET_ARCH}/python:${TARGET_VERSION} AS builder |
9 | 9 |
|
10 | 10 | WORKDIR /tmp/build |
11 | 11 |
|
12 | | -COPY . /tmp/build |
| 12 | +COPY pyproject.toml poetry.lock /tmp/build/ |
| 13 | + |
| 14 | +RUN apk add --no-cache --virtual .build-deps build-base libffi-dev && \ |
| 15 | + pip install --no-cache-dir 'poetry==2.4.1' && \ |
| 16 | + poetry config virtualenvs.create false && \ |
| 17 | + poetry install --without dev --extras cli --extras tunnel --no-interaction --no-ansi --no-root |
| 18 | + |
| 19 | +COPY . /tmp/build/ |
| 20 | + |
| 21 | +RUN poetry build --format wheel --no-interaction |
13 | 22 |
|
14 | | -RUN _poetry_venv_dir="$(mktemp -d -p "${TMPDIR:-/tmp}" 'poetry_venv.XXXXXX')" && \ |
15 | | - apk add --no-cache libffi && \ |
16 | | - apk add --no-cache --virtual .build-deps build-base libffi-dev && \ |
17 | | - python -m 'venv' "${_poetry_venv_dir}" && \ |
18 | | - "${_poetry_venv_dir}/bin/pip" install --no-cache-dir 'poetry' && \ |
19 | | - "${_poetry_venv_dir}/bin/poetry" config --local virtualenvs.create false && \ |
20 | | - "${_poetry_venv_dir}/bin/poetry" install --without dev --extras cli --extras tunnel --no-interaction --no-ansi && \ |
21 | | - apk del .build-deps && \ |
| 23 | +FROM docker.io/${TARGET_ARCH}/python:${TARGET_VERSION} |
| 24 | + |
| 25 | +RUN apk add --no-cache libffi && \ |
22 | 26 | addgroup -S meshtastic && \ |
23 | | - adduser -S -G meshtastic -h /home/meshtastic meshtastic && \ |
24 | | - rm -f -r "${_poetry_venv_dir}" && \ |
25 | | - rm -f -r "/tmp/build" |
| 27 | + adduser -S -G meshtastic -h /home/meshtastic meshtastic |
| 28 | + |
| 29 | +COPY --from=builder /tmp/build/dist/*.whl /tmp/ |
| 30 | + |
| 31 | +RUN wheel=$(echo /tmp/meshtastic-*.whl) && pip install --no-cache-dir "${wheel}[cli,tunnel]" && \ |
| 32 | + rm -f /tmp/meshtastic-*.whl |
26 | 33 |
|
27 | 34 | COPY "./bin/container-entrypoint.sh" "/init" |
28 | 35 | RUN chmod 0755 /init |
|
0 commit comments