From 4836e1975a51c49444d291f97ce72416362a26a3 Mon Sep 17 00:00:00 2001 From: James Robinson Date: Mon, 30 Sep 2024 11:36:45 +0100 Subject: [PATCH] TMP --- Dockerfile | 58 +++++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index feb5658..0bb0bb2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,38 +13,42 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && \ apt-get install -y \ dumb-init \ - g++ \ - gcc \ - libldap2-dev \ + # g++ \ + # gcc \ + # libldap2-dev \ libpq-dev \ - libsasl2-dev \ + # libsasl2-dev \ patchelf \ pipx \ python3-dev \ - wget \ + # wget \ && \ - pipx install hatch + pipx install auditwheel && \ + pipx install hatch; -## Copy project files needed by hatch -COPY README.md pyproject.toml ./ -COPY guacamole_user_sync guacamole_user_sync - -## Build wheels for dependencies then use auditwheel to include shared libraries +## Use hatch to generate requirements file ## Note that we need to specify psycopg[c] in order to ensure that dependencies are included in the wheel +COPY README.md pyproject.toml ./ +COPY guacamole_user_sync/*.py guacamole_user_sync/ RUN /root/.local/bin/hatch run pip freeze | grep -v "^-e" > requirements.txt && \ - sed -i "s/psycopg=/psycopg[c]=/g" requirements.txt && \ - python -m pip wheel --no-cache-dir --no-binary :all: --wheel-dir /app/repairable -r requirements.txt && \ - python -m pip install auditwheel && \ - mkdir -p /app/wheels && \ - for WHEEL in /app/repairable/*.whl; do \ - auditwheel repair --wheel-dir /app/wheels --plat manylinux_2_34_aarch64 "${WHEEL}" 2> /dev/null || mv "${WHEEL}" /app/wheels/; \ - done; - -## Build a separate pip wheel which can be used to install itself -RUN python -m pip wheel --no-cache-dir --wheel-dir /app/wheels pip && \ - mv /app/wheels/pip*whl /app/wheels/pip-0-py3-none-any.whl + sed -i "s/psycopg=/psycopg[c]=/g" requirements.txt -## Build a separate wheel for the project +## Build a wheel for pip which can be used to install itself +RUN python -m pip wheel --no-cache-dir --wheel-dir /app/wheels pip && \ + mv /app/wheels/pip*whl /app/wheels/pip-0-py3-none-any.whl; + +## Build wheels for dependencies using auditwheel to include shared libraries +RUN python -m pip wheel --no-cache-dir --no-binary :all: --wheel-dir /app/repairable -r requirements.txt; +RUN for WHEEL in /app/repairable/*.whl; do \ + echo "Repairing $WHEEL" && \ + /root/.local/bin/auditwheel repair --verbose --wheel-dir /app/wheels --plat manylinux_2_34_aarch64 "${WHEEL}" 2> /dev/null || mv "${WHEEL}" /app/wheels/; \ + done && \ + ls -alh /app/wheels/ /app/repairable && \ + rm -rf /app/repairable && \ + ls -alh /app/wheels/; + +## Build a wheel for guacamole_user_sync +COPY guacamole_user_sync guacamole_user_sync RUN /root/.local/bin/hatch build -t wheel && \ mv dist/guacamole_user_sync*.whl /app/wheels/ && \ echo "guacamole-user-sync>=0.0" >> requirements.txt @@ -70,10 +74,10 @@ COPY synchronise.py . ## Install pip from wheel RUN python /tmp/wheels/pip-0-py3-none-any.whl/pip install \ - --break-system-packages \ - --root-user-action ignore \ - --no-index \ - /tmp/wheels/pip-0-py3-none-any.whl && \ + --break-system-packages \ + --root-user-action ignore \ + --no-index \ + /tmp/wheels/pip-0-py3-none-any.whl && \ rm /tmp/wheels/pip-0-py3-none-any.whl ## Install Python packages from wheels