Skip to content

Commit 29222f8

Browse files
committed
add biosim cloud build ci
1 parent 8bd2587 commit 29222f8

5 files changed

Lines changed: 218 additions & 0 deletions

File tree

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
# Check for updates to GitHub Actions every day
12+
interval: "daily"
13+
time: "09:00"
14+
timezone: "UTC"
15+
assignees:
16+
- "jimboid"

.github/workflows/build.yaml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: ci/cd
2+
on:
3+
pull_request:
4+
repository_dispatch:
5+
types: [build]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
timeout-minutes: 360
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
platform:
15+
- linux/amd64
16+
#- linux/arm64
17+
runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-24.04' || matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' }}
18+
name: build ${{ matrix.platform }}
19+
outputs:
20+
tag: ${{ steps.envvars.outputs.tag }}
21+
steps:
22+
- name: checkout
23+
uses: actions/checkout@v5.0.0
24+
25+
- name: Prepare env
26+
id: envvars
27+
run: |
28+
platform=${{ matrix.platform }}
29+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
30+
if [ ${{ github.event.client_payload.tag }} != 'null' ]; then
31+
echo "tag=${{ github.event.client_payload.tag }}" >> $GITHUB_OUTPUT
32+
else
33+
echo "tag=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
34+
fi
35+
36+
- name: Metadata
37+
id: meta
38+
uses: docker/metadata-action@v5.8.0
39+
with:
40+
images: ghcr.io/${{ vars.ORG_REPO }}/${{ github.event.repository.name }}
41+
42+
- name: Authenticate with GHCR
43+
id: auth
44+
uses: docker/login-action@v3.6.0
45+
with:
46+
registry: ghcr.io
47+
username: ${{ github.repository_owner }}
48+
password: ${{ secrets.BUILD_TOKEN }}
49+
50+
- name: Set up Docker Buildx
51+
id: buildx
52+
uses: docker/setup-buildx-action@v3.11.1
53+
54+
- name: Build and push by digest
55+
id: build
56+
uses: docker/build-push-action@v6.18.0
57+
with:
58+
file: ./docker/Dockerfile
59+
platforms: ${{ matrix.platform }}
60+
labels: ${{ steps.meta.outputs.labels }}
61+
tags: ghcr.io/${{ vars.ORG_REPO }}/${{ github.event.repository.name }}
62+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
63+
64+
#- name: Test notebooks
65+
# shell: bash
66+
# run: |
67+
# docker run -t ghcr.io/${{ vars.ORG_REPO }}/${{ github.event.repository.name }}@${{ steps.build.outputs.digest }} bash -c " \
68+
# pip install pytest nbmake; \
69+
# find ./notebooks -name '*.ipynb' | pytest --nbmake --nbmake-timeout=3600;"
70+
71+
- name: Export digest
72+
run: |
73+
mkdir -p ${{ runner.temp }}/digests
74+
digest="${{ steps.build.outputs.digest }}"
75+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
76+
77+
- name: Upload digest
78+
uses: actions/upload-artifact@v4.6.2
79+
with:
80+
name: digests-${{ env.PLATFORM_PAIR }}
81+
path: ${{ runner.temp }}/digests/*
82+
if-no-files-found: error
83+
retention-days: 1
84+
85+
tags:
86+
if: github.event_name != 'pull_request'
87+
runs-on: ubuntu-24.04
88+
name: merge and tag
89+
needs:
90+
- build
91+
steps:
92+
- name: Download digests
93+
uses: actions/download-artifact@v5.0.0
94+
with:
95+
path: ${{ runner.temp }}/digests
96+
pattern: digests-*
97+
merge-multiple: true
98+
99+
- name: Authenticate with GHCR
100+
id: auth
101+
uses: docker/login-action@v3.6.0
102+
with:
103+
registry: ghcr.io
104+
username: ${{ github.repository_owner }}
105+
password: ${{ secrets.BUILD_TOKEN }}
106+
107+
- name: Set up Docker Buildx
108+
id: buildx
109+
uses: docker/setup-buildx-action@v3.11.1
110+
111+
- name: Metadata
112+
id: meta
113+
uses: docker/metadata-action@v5.8.0
114+
with:
115+
images: ghcr.io/${{ vars.ORG_REPO }}/${{ github.event.repository.name }}
116+
tags: |
117+
latest
118+
${{ needs.build.outputs.tag }}
119+
120+
- name: Create manifest list and push
121+
id: annotate
122+
continue-on-error: true
123+
working-directory: ${{ runner.temp }}/digests
124+
run: |
125+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
126+
--annotation='index:org.opencontainers.image.description=${{ github.event.repository.description }}' \
127+
--annotation='index:org.opencontainers.image.licenses=MIT' \
128+
--annotation='index:org.opencontainers.image.created=${{ steps.timestamp.outputs.timestamp }}' \
129+
--annotation='index:org.opencontainers.image.url=${{ github.event.repository.url }}' \
130+
--annotation='index:org.opencontainers.image.source=${{ github.event.repository.url }}' \
131+
$(printf 'ghcr.io/${{ vars.ORG_REPO }}/${{ github.event.repository.name }}@sha256:%s ' *)
132+
133+
- name: Create manifest list and push without annotations
134+
if: steps.annotate.outcome == 'failure'
135+
working-directory: ${{ runner.temp }}/digests
136+
run: |
137+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
138+
$(printf 'ghcr.io/${{ vars.ORG_REPO }}/${{ github.event.repository.name }}@sha256:%s ' *)
139+
140+
- name: Inspect image
141+
run: |
142+
docker buildx imagetools inspect ghcr.io/${{ vars.ORG_REPO }}/${{ github.event.repository.name }}:latest
143+
144+
- name: Post version update to dash
145+
uses: peter-evans/repository-dispatch@v4.0.0
146+
with:
147+
token: ${{ secrets.BUILD_TOKEN }}
148+
repository: ccpbiosim/ccpbiosim.github.io
149+
event-type: build
150+
client-payload: '{"repo": "${{ github.event.repository.name }}", "tag": "${{ needs.build.outputs.tag }}"}'

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 CCPBioSim
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

docker/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Start with BioSim base image.
2+
ARG BASE_IMAGE=latest
3+
FROM ghcr.io/jimboid/biosim-jupyterhub-base:$BASE_IMAGE
4+
5+
LABEL maintainer="James Gebbie-Rayet <james.gebbie@stfc.ac.uk>"
6+
7+
ARG TARGETPLATFORM
8+
9+
# Switch to jovyan user.
10+
USER $NB_USER
11+
WORKDIR $HOME
12+
13+
# Dependencies for the workshop
14+
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
15+
conda install conda-forge/linux-64::gromacs=2024.5=nompi_h5f56185_100 -y; \
16+
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
17+
conda install conda-forge/linux-aarch64::gromacs=2024.5=nompi_h9afd374_100 -y; \
18+
fi
19+
RUN conda install ipywidgets nglview -y
20+
RUN pip install mdtraj
21+
22+
# Get workshop files and move them to jovyan directory.
23+
COPY --chown=1000:100 . .
24+
RUN rm -rf LICENSE README.md docker .git .github
25+
26+
# Copy lab workspace
27+
COPY --chown=1000:100 default-37a8.jupyterlab-workspace /home/jovyan/.jupyter/lab/workspaces/default-37a8.jupyterlab-workspace
28+
29+
# Always finish with non-root user as a precaution.
30+
USER $NB_USER
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"data":{"layout-restorer:data":{"main":{"dock":{"type":"split-area","orientation":"horizontal","sizes":[0.5,0.5],"children":[{"type":"tab-area","currentIndex":0,"widgets":["terminal:1"]},{"type":"tab-area","currentIndex":0,"widgets":["notebook:D-NEMD_tutorial.ipynb"]}]},"current":"notebook:D-NEMD_tutorial.ipynb"},"left":{"collapsed":false,"current":"filebrowser","widgets":["filebrowser","running-sessions","@jupyterlab/toc:plugin","extensionmanager.main-view"]},"right":{"collapsed":true,"widgets":["jp-property-inspector"]}},"notebook:D-NEMD_tutorial.ipynb":{"data":{"path":"D-NEMD_tutorial.ipynb","factory":"Notebook"}},"terminal:1":{"data":{"name":"1"}}},"metadata":{"id":"default"}}

0 commit comments

Comments
 (0)