From 50db33d6bca42cf01128c6cdeaa622f4f6330773 Mon Sep 17 00:00:00 2001 From: Marcel Stimberg Date: Thu, 7 Mar 2024 18:17:00 +0100 Subject: [PATCH] Use local wheels in docker build --- .github/workflows/publish.yml | 10 ++++++++-- docker/Dockerfile | 23 ++++++++++++----------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3abc958ef..e90f131a5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -135,7 +135,7 @@ jobs: name: Build docker image for release runs-on: ubuntu-latest environment: release - needs: deploy + needs: build-linux steps: - name: Checkout repository uses: actions/checkout@v4 @@ -170,7 +170,13 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push the Docker image + - name: load distribution 📦 + uses: actions/download-artifact@v3 + with: + name: packages + pattern: *cp312*.whl + path: dist/ + - name: Build (and potentially push) the Docker image uses: docker/build-push-action@v5 # https://github.com/docker/build-push-action with: diff --git a/docker/Dockerfile b/docker/Dockerfile index 9bb555fe6..79b3266e0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -19,22 +19,23 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ g++ \ git \ - libgs-dev \ - python3-dev \ - sudo + sudo \ + && rm -rf /var/lib/apt/lists/* -# Update system to use Python3 by default -RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 +# Copy wheels into the image +COPY dist /tmp/dist -# Install Brian and recommended packages -RUN pip install \ - brian2 \ - brian2tools \ +# Install Brian2 and recommended packages +ARG TARGETARCH +RUN pip install --no-cache-dir --only-binary=:all: \ scipy \ matplotlib \ jupyterlab \ pytest \ - pytest-xdist + pytest-xdist \ + && if [ "${TARGETARCH}" = "arm64" ]; then WHEEL_ARCH=aarch64; else WHEEL_ARCH=x86_64; fi \ + && pip install /tmp/dist/Brian2*_${WHEEL_ARCH}.whl brian2tools \ + && rm -rf /tmp/dist # Create a non-root user ARG USER="monty" \ @@ -58,4 +59,4 @@ RUN git clone https://github.com/brian-team/brian2.git \ && rm -rf brian2 EXPOSE 8888 -CMD ["jupyter", "lab", "--ip=0.0.0.0"] +CMD ["jupyter", "lab", "--ip=0.0.0.0", "--no-browser"]