-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters