From 5949fe655575921864121aecfbc47a5735ba4f06 Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Wed, 24 Jun 2026 09:23:26 +0000 Subject: [PATCH 1/2] feat(images): add a container image for running ptypy workflows --- .github/workflows/_ptypy-workflows.yml | 61 +++++++++++++++++++++++++ .github/workflows/ci.yml | 13 ++++-- images/ptypy_workflows/Dockerfile | 24 ++++++++++ images/ptypy_workflows/environment.yaml | 13 ++++++ 4 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/_ptypy-workflows.yml create mode 100644 images/ptypy_workflows/Dockerfile create mode 100644 images/ptypy_workflows/environment.yaml diff --git a/.github/workflows/_ptypy-workflows.yml b/.github/workflows/_ptypy-workflows.yml new file mode 100644 index 0000000..c644977 --- /dev/null +++ b/.github/workflows/_ptypy-workflows.yml @@ -0,0 +1,61 @@ +on: + workflow_call: + inputs: + publish: + type: boolean + description: If true, pushes image to container registry + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Docker Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and export to Docker local cache + uses: docker/build-push-action@v6 + env: + DOCKER_BUILD_RECORD_UPLOAD: false + with: + context: images/ptypy_workflows + file: images/ptypy_workflows/Dockerfile + # Need load and tags so we can test it below + load: true + tags: tag_for_testing + + - name: Create tags for publishing image + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=ref,event=tag + type=raw,value=latest + + - name: Push cached image to container registry + if: inputs.publish && github.ref_type == 'tag' + uses: docker/build-push-action@v6 + env: + DOCKER_BUILD_RECORD_UPLOAD: false + # This does not build the image again, it will find the image in the + # Docker cache and publish it + with: + context: images/ptypy_workflows + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 982756f..db02b06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,11 +5,10 @@ on: branches: - main tags: - - '*' + - "*" pull_request: jobs: - lint: uses: ./.github/workflows/_tox.yml with: @@ -36,16 +35,22 @@ jobs: contents: read packages: write + ptypy-workflows: + uses: ./.github/workflows/_ptypy-workflows.yml + permissions: + contents: read + packages: write + dist: uses: ./.github/workflows/_dist.yml - + pypi: needs: [dist, test] if: github.ref_type == 'tag' uses: ./.github/workflows/_pypi.yml permissions: id-token: write - + release: needs: [dist, test] if: github.ref_type == 'tag' diff --git a/images/ptypy_workflows/Dockerfile b/images/ptypy_workflows/Dockerfile new file mode 100644 index 0000000..75cc8de --- /dev/null +++ b/images/ptypy_workflows/Dockerfile @@ -0,0 +1,24 @@ +FROM quay.io/condaforge/miniforge3 AS build + +COPY environment.yaml . +RUN conda env create -f environment.yaml && \ + conda install -c conda-forge conda-pack && \ + conda clean --all --yes && \ + conda-pack -n ptypy_workflow -o /tmp/env.tar && \ + mkdir /venv && cd /venv && tar xf /tmp/env.tar && \ + rm /tmp/env.tar && \ + rm -rf /opt/conda/pkgs + +RUN /venv/bin/conda-unpack + +# Install system dependencies and clean up +RUN apt-get update && \ + apt-get install -y curl unzip && \ + rm -rf /var/lib/apt/lists/* + + +FROM ubuntu:resolute AS runtime + +COPY --from=build /venv /venv + +ENV PATH="/venv/bin:$PATH" diff --git a/images/ptypy_workflows/environment.yaml b/images/ptypy_workflows/environment.yaml new file mode 100644 index 0000000..26c0bbb --- /dev/null +++ b/images/ptypy_workflows/environment.yaml @@ -0,0 +1,13 @@ +name: ptypy_workflow +channels: + - conda-forge +dependencies: + - python=3.14 + - matplotlib + - jupyter + - nbconvert + - papermill + - h5py + - pip + - pip: + - git+https://github.com/ptycho/ptypy@master From e9cb004b934a69822d77d0ca03531d118d786d0b Mon Sep 17 00:00:00 2001 From: NatLeung96 Date: Wed, 1 Jul 2026 10:58:41 +0000 Subject: [PATCH 2/2] feat(images): update dependencies for ptypy_workflows --- images/ptypy_workflows/environment.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/images/ptypy_workflows/environment.yaml b/images/ptypy_workflows/environment.yaml index 26c0bbb..de5da2a 100644 --- a/images/ptypy_workflows/environment.yaml +++ b/images/ptypy_workflows/environment.yaml @@ -3,6 +3,14 @@ channels: - conda-forge dependencies: - python=3.14 + - numpy + - scipy + - pyzmq + - mpi4py + - packaging + - pillow + - pyfftw + - pyyaml - matplotlib - jupyter - nbconvert