Skip to content

Commit

Permalink
Push Apptainer Image to GHCR + Build Installer & Docker Image using C…
Browse files Browse the repository at this point in the history
…onda-Forge Package (#353)

* see if this can push to ghcr

* fix URI

* don't push docker image

* don't push docker image

* see if this lets us login to ghcr

* we can push to github's container registry directly

* now when we trigger a build, we build the latest version we can discover from the tags

* forgot to remove bit where we install package from source

* use docker ignore to make sure we keep the context as small as we can

* make it explicit we don't push before we test, and make sure we have the same build args for when we do push

* add juypterlab and notebook to docker image

* Apply suggestions from code review
  • Loading branch information
mikemhenry authored Apr 25, 2023
1 parent 4701636 commit fa83040
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 38 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore everything
*

# Only allow
!production/environment.yml
20 changes: 8 additions & 12 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ jobs:
- name: Print FQIRP
run: echo ${{ steps.fqirp.outputs.FQIRP }}

- name: Build package at the latest tag
run: |
python3 -m pip install --upgrade build
python3 -m build
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
Expand Down Expand Up @@ -92,8 +87,11 @@ jobs:
context: .
file: production/Dockerfile
load: true
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.latest-version.outputs.VERSION }}
- name: Test image
run: |
Expand All @@ -111,6 +109,8 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.latest-version.outputs.VERSION }}
- name: Setup Apptainer
uses: eWaterCycle/setup-apptainer@v2
Expand All @@ -120,16 +120,12 @@ jobs:
- name: Build Apptainer Image
run: singularity build openfe_${{ steps.latest-version.outputs.VERSION }}.sif docker-daemon:${{ steps.fqirp.outputs.FQIRP }}

- name: Test Apptainer Image
- name: Test & Push Apptainer Image
run: |
mkdir test_apptainer
cd test_apptainer
singularity run ../openfe_${{ steps.latest-version.outputs.VERSION }}.sif --help
singularity run ../openfe_${{ steps.latest-version.outputs.VERSION }}.sif --version
singularity run ../openfe_${{ steps.latest-version.outputs.VERSION }}.sif pytest --pyargs openfecli --pyargs openfe -v -n auto
cd ../
- uses: actions/upload-artifact@v3
with:
name: openfe_${{ steps.latest-version.outputs.VERSION }}.sif
path: openfe_${{ steps.latest-version.outputs.VERSION }}.sif
echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ secrets.GHCR_USERNAME }} --password-stdin oras://ghcr.io
singularity push ../openfe_${{ steps.latest-version.outputs.VERSION }}.sif oras://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.latest-version.outputs.VERSION }}-apptainer
4 changes: 3 additions & 1 deletion devtools/installer/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ transmute_file_type: .conda

specs:
- conda
- gufe=={{ environ["VERSION"] }}
- jupyterlab
- mamba
- notebook
- openfe=={{ environ["VERSION"] }}
- pip
- pytest
- pytest-xdist
- python 3.9.*

# Not building an .exe for windows or a .pkg for macOS
Expand Down
6 changes: 3 additions & 3 deletions production/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ FROM mambaorg/micromamba:1.4.1
LABEL org.opencontainers.image.source=https://github.com/OpenFreeEnergy/openfe
LABEL org.opencontainers.image.description="A Python package for executing alchemical free energy calculations."
LABEL org.opencontainers.image.licenses=MIT
# OpenFE Version we want to build
ARG VERSION

# Don't buffer stdout & stderr streams, so if there is a crash no partial buffer output is lost
# https://docs.python.org/3/using/cmdline.html#cmdoption-u
ENV PYTHONUNBUFFERED=1

COPY --chown=$MAMBA_USER:$MAMBA_USER production/environment.yml /tmp/env.yaml
COPY --chown=$MAMBA_USER:$MAMBA_USER dist/*py3-none-any.whl /tmp
RUN micromamba install -y -n base git -f /tmp/env.yaml && \
RUN micromamba install -y -n base git "openfe==$VERSION" -f /tmp/env.yaml && \
micromamba clean --all --yes

# Ensure that conda environment is automatically activated
# https://github.com/mamba-org/micromamba-docker#running-commands-in-dockerfile-within-the-conda-environment
ARG MAMBA_DOCKERFILE_ACTIVATE=1
RUN python -m pip install --no-deps *py3-none-any.whl
25 changes: 3 additions & 22 deletions production/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,13 @@ name: openfe
channels:
- conda-forge
dependencies:
- click
# Issues with 11.8 on lilac
- cudatoolkit==11.7
- gufe==0.7.*
- libnetcdf<4.9
- lomap2>=2.1.0
- networkx
- numpy<1.24
- openff-models>=0.0.4
- openff-toolkit>=0.12.0
- openff-units>=0.2.0
- openmmforcefields>=0.11.2
- openmmtools==0.21.5
- jupyterlab
- notebook
- openfe
- pip
- plugcli
- py3dmol
- pydantic
- pytest
- pytest-xdist
- python==3.9
- rdkit
- typing-extensions
# build time dep
- versioningit
# docs
- myst-parser
- sphinx-click
- pydata-sphinx-theme
- autodoc-pydantic

0 comments on commit fa83040

Please sign in to comment.