From 725da583dc6bda46402c7fbe96e45201283ae5b3 Mon Sep 17 00:00:00 2001 From: banesullivan Date: Tue, 26 Apr 2022 10:08:05 -0600 Subject: [PATCH] Add Python-slim Docker image --- .dockerignore | 7 ------- .github/workflows/docker.yml | 37 ++++++++++++++++++++++++++++++++++++ slim.Dockerfile | 31 ++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/docker.yml create mode 100644 slim.Dockerfile diff --git a/.dockerignore b/.dockerignore index ba3d153be..206320cc1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,9 +1,2 @@ build test -.git -girder -girder_annotation -large_image -sources -utilities -examples diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..872e88e5d --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,37 @@ +name: Docker Package +on: + push: + tags: "*" + branches: + - master + pull_request: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-publish: + runs-on: ubuntu-latest + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository ) + steps: + - uses: actions/checkout@v2 + - name: Log into the Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: token + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata for the Docker image + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push the Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: slim.Dockerfile + push: ${{ github.actor != 'dependabot[bot]' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/slim.Dockerfile b/slim.Dockerfile new file mode 100644 index 000000000..603a87e4e --- /dev/null +++ b/slim.Dockerfile @@ -0,0 +1,31 @@ +# Build wheels +FROM python:3.9-slim as build + +# Need git for setuptools_scm +RUN apt-get update \ + && apt-get install -y --no-install-recommends git \ + && apt-get purge -y --auto-remove \ + && rm -rf /var/lib/apt/lists/* + +COPY . /opt/build-context/ +WORKDIR /opt/build-context + +RUN python -m pip install --upgrade pip wheel setuptools +RUN sh .circleci/make_wheels.sh +RUN mv ~/wheels /opt/build-context/ + +# Production +FROM python:3.9-slim + +COPY --from=build /opt/build-context/wheels /opt/wheels +LABEL maintainer="Kitware, Inc. " +LABEL repo="https://github.com/girder/large_image" +# NOTE: this does not install any girder3 packages +RUN pip install \ + --find-links https://girder.github.io/large_image_wheels \ + --find-links=/opt/wheels \ + 'pylibmc>=1.5.1' \ + matplotlib \ + pyvips \ + simplejpeg \ + $(ls -1 /opt/wheels/large_image*.whl)