Skip to content

Commit

Permalink
added dockerfile (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
thawn authored May 10, 2024
1 parent afab41f commit c3c8d9d
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 0 deletions.
120 changes: 120 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# This workflow will build two Docker image and push then to GitHub Packages Container registry:
# - a base image with the dependencies
# - a main image with the application code

name: Docker

on:
push:
branches: [main]
paths:
- 'docker/**'
- '.github/workflows/docker-base.yml'
- 'conda/*.yml'
- 'pyproject.toml'
pull_request:
branches: [main]
paths:
- 'docker/**'
- '.github/workflows/docker-base.yml'
- 'conda/*.yml'
- 'pyproject.toml'
release:
types: [published]

jobs:
build_docker_images:
strategy:
matrix:
RAPIDS_VER:
- 24.04
name: Build Docker images
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
steps:
- name: Maximize build disk space
uses: easimon/maximize-build-space@v10
with:
remove-dotnet: true
remove-android: true
remove-haskell: true
remove-codeql: true
root-reserve-mb: 35840
swap-size-mb: 1048

- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker base image
id: meta-base
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}-deps
- name: create yaml file for conda environment
run: |
grep -v -- '- rapids-singlecell' conda/rsc_rapids_${{ matrix.RAPIDS_VER }}.yml > docker/rsc_rapids.yml
shell: bash

- name: Build and push Docker base images
id: push-base
uses: docker/build-push-action@v5
with:
context: ./docker/
file: ./docker/Dockerfile.deps
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.meta-base.outputs.tags }}
labels: ${{ steps.meta-base.outputs.labels }}
#cache-from: type=registry,ref=ghcr.io/${{ github.repository }}-deps

- name: Generate artifact attestation for base image
if: github.event_name == 'release'
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push-base.outputs.digest }}
push-to-registry: true

- name: Extract metadata (tags, labels) for main Docker image
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
- name: Build and push main Docker images
id: push
uses: docker/build-push-action@v5
with:
context: ./docker/
file: ./docker/Dockerfile
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
#cache-from: type=registry,ref=ghcr.io/${{ github.repository }}
build-contexts: |
rapids-singlecell-deps=docker-image://${{ steps.meta-base.outputs.tags }}
- name: Generate artifact attestation for main image
if: github.event_name == 'release'
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

- name: list docker images
run: |
docker image ls -a
shell: bash
20 changes: 20 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM rapids-singlecell-deps

ARG GIT_ID=main

SHELL ["/bin/bash", "-euo", "pipefail", "-c"]

ENV PATH=/opt/conda/bin:$PATH

RUN <<EOF
# install rapids_singlecell from source
set -x
mkdir /src
cd /src
git clone https://github.com/scverse/rapids_singlecell.git
cd rapids_singlecell
git checkout ${GIT_ID}
/opt/conda/bin/python -m pip install --no-cache-dir -e .
EOF

ENTRYPOINT ["/opt/conda/bin/ipython"]
40 changes: 40 additions & 0 deletions docker/Dockerfile.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ARG CUDA_VER=11.8.0
ARG LINUX_VER=ubuntu22.04

FROM nvidia/cuda:${CUDA_VER}-base-${LINUX_VER}

SHELL ["/bin/bash", "-euo", "pipefail", "-c"]

ARG PYTHON_VER=3.11

ENV PATH=/opt/conda/bin:$PATH
ENV PYTHON_VERSION=${PYTHON_VER}

COPY --from=condaforge/miniforge3:24.3.0-0 /opt/conda /opt/conda

COPY rsc_rapids.yml rsc_rapids.yml

ARG GIT_ID=main
ARG DEBIAN_FRONTEND=noninteractive

RUN <<EOF
# install conda environment
set -x
apt-get -qq update
apt-get -q -o=Dpkg::Use-Pty=0 -y dist-upgrade
apt-get -q install -y -o=Dpkg::Use-Pty=0 git
apt-get -q clean -y
mamba env update -n base -f rsc_rapids.yml
mamba install -y -n base pytest -c conda-forge
mamba clean -afy
EOF

RUN <<EOF
# install rapids_singlecell dependencies
set -x
/opt/conda/bin/python -m pip install --no-cache-dir git+https://github.com/scverse/rapids_singlecell.git@${GIT_ID}
/opt/conda/bin/python -m pip uninstall -y --no-cache-dir rapids-singlecell
/opt/conda/bin/python -m pip cache purge
EOF

ENTRYPOINT ["/opt/conda/bin/ipython"]
12 changes: 12 additions & 0 deletions docker/docker-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -euxo pipefail

docker_account=scverse
rapids_version=24.04
grep -v -- '- rapids-singlecell' conda/rsc_rapids_${rapids_version}.yml > rsc_rapids.yml
docker build -t rapids-singlecell-deps:latest -f docker/Dockerfile.deps .
rm rsc_rapids.yml
docker build -t rapids-singlecell:latest -f docker/Dockerfile .
latest_id=$( docker images |grep -e "rapids-singlecell[ \t]*latest"|head -n1|awk '{print $3}' )
#docker tag $latest_id $docker_account/rapids-singlecell:latest
#docker push $docker_account/rapids-singlecell:latest
2 changes: 2 additions & 0 deletions docs/release-notes/0.10.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
```{rubric} Features
```
* adds the flavor `seurat_v3_paper` to `pp.highly_variable_genes` {pr}`170` {smaller}`S Dicks`
* build docker images in github CI {pr}`177` {smaller}`T Korten (HZDR/Helmholtz AI)`

```{rubric} Performance
```
Expand All @@ -12,6 +13,7 @@
* updates `pp.highly_variable_genes` for the flavors `seurat` and `cell_ranger` {pr}`183` {smaller}`S Dicks`
* `pp.scale` now uses `RawKernels` for dense and csr {pr}`185` {smaller}`S Dicks`


```{rubric} Bug fixes
```
* fixes a bug where the `pp.scale` would have issues with `int64` indexing {pr}`187` {smaller}`S Dicks`
Expand Down

0 comments on commit c3c8d9d

Please sign in to comment.