|
| 1 | +# Singularity Deploy |
| 2 | + |
| 3 | +[](https://github.com/singularityhub/singularity-deploy/actions?query=branch%3Amain+workflow%3Asingularity-deploy) |
| 4 | +[](https://github.com/singularityhub/singularity-deploy/actions?query=branch%3Amain+workflow%3Asingularity-deploy-test) |
| 5 | + |
| 6 | +Wouldn't it be nice to build Singularity images without a registry proper, |
| 7 | +and just keep them alongside the GitHub codebase? This is now possible! |
| 8 | +This small repository provides an example to get you started. It will |
| 9 | +build one or more images (whatever Singularity.* files that are present at |
| 10 | +the root) and then release them as assets to your GitHub repository so |
| 11 | +that they can be programatically obtained. Note that assets are limited to |
| 12 | +2 GB in size, which is still fairly good. You can use |
| 13 | +it as a template for your own recipes as is, or modify it for your custom |
| 14 | +use case. Instructions are below! |
| 15 | + |
| 16 | +## Getting Started |
| 17 | + |
| 18 | +### 1. Template or Fork |
| 19 | + |
| 20 | +If you haven't already, template or fork this repository. You can then clone |
| 21 | +your fork: |
| 22 | + |
| 23 | +```bash |
| 24 | +$ git clone [email protected]: <username >/singularity-deploy |
| 25 | +``` |
| 26 | + |
| 27 | +You likely want to name the repository by the container. For example, if I would |
| 28 | +have created a container on Docker Hub or similar with the name `vsoch/salad`, |
| 29 | +here I'd call the repository `salad`. You obviously are limited to your username |
| 30 | +or an organizational namespace. |
| 31 | + |
| 32 | +### 1. Write your Singularity Recipe(s) |
| 33 | + |
| 34 | +First, you should write your container recipe(s) in the present working directory. |
| 35 | +For good practice, when you are updating recipes you should checkout a new branch |
| 36 | +and open a pull request, as the repository comes with a workflow to trigger on a PR |
| 37 | +to [test your container build](.github/workflows/test.yml). You can add any additional |
| 38 | +tests that that you might need. By default, any Singularity.* file will be automatically detected. |
| 39 | +If there is no extension (the name Singularity), the name used will be "latest." |
| 40 | +You can use these tags across multiple releases of your containers. For example, |
| 41 | +these files would generate packages with sifs named as follows: |
| 42 | + |
| 43 | + - [Singularity](Singularity) maps to [https://github.com/singularityhub/singularity-deploy/releases/download/0.0.1/singularityhub-singularity-deploy.latest.sif](https://github.com/singularityhub/singularity-deploy/releases/download/0.0.1/singularityhub-singularity-deploy.latest.sif) |
| 44 | + - [Singularity.pokemon](Singularity.pokemon) maps to [https://github.com/singularityhub/singularity-deploy/releases/download/0.0.1/singularityhub-singularity-deploy.pokemon.sif](https://github.com/singularityhub/singularity-deploy/releases/download/0.0.1/singularityhub-singularity-deploy.pokemon.sif) |
| 45 | + - [Singularity.salad](Singularity.salad) maps to [https://github.com/singularityhub/singularity-deploy/releases/download/0.0.1/singularityhub-singularity-deploy.latest.sif](https://github.com/singularityhub/singularity-deploy/releases/download/0.0.1/singularityhub-singularity-deploy.latest.sif) |
| 46 | + |
| 47 | +For each name, you can see the direct download URL contains the repository (singularityhub/singularity-deploy), |
| 48 | +You should not use any `:` characters in either your container tag (the GitHub extension) or |
| 49 | +the GitHub tags (the release tags) as this might interfere with parsing. |
| 50 | +The GitHub release tag (0.0.1 in the example above) is discussed next. |
| 51 | + |
| 52 | +### 2. Update the VERSION file |
| 53 | + |
| 54 | +Any time that you prepare new container recipes, you should update the [VERSION](VERSION) |
| 55 | +file. The way that this repository works is to generate a release based on the |
| 56 | +string in `VERSION`. A version is just a tag, so it could be something like |
| 57 | +`0.0.1` or `0.0.1-slim`. Keep in mind that GitHub releases cannot have duplicated |
| 58 | +names, so you should not repeat the same tag. Do not use `:` in your tag names. |
| 59 | +If you do need to re-release a tag (not recommended if a user might be using it and then it's changed) you can manually delete |
| 60 | +the release and the tag in the GitHub interface. This is a nice structure because it |
| 61 | +means you can have containers with different names under the same tag. In the example |
| 62 | +above, we have each of "deploy," "latest," and "salad" released under tag 0.0.1. |
| 63 | +This is how it looks on GitHub: |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +### 3. How to Develop |
| 68 | + |
| 69 | +As we mentioned previously, the container builds will be tested on a pull request, |
| 70 | +and the release will trigger on merge into your main branch (main). See the [.github/workflows/builder.yml](.github/workflows/builder.yml)) |
| 71 | +to edit this. The idea is that you can: |
| 72 | + |
| 73 | +1. Develop your container via a development branch |
| 74 | +2. Open a pull request to test the container (the [.github/workflows/test.yml](.github/workflows/test.yml)) |
| 75 | +3. On merge, your container will be released! |
| 76 | + |
| 77 | +### 4. How to pull |
| 78 | + |
| 79 | +Technically, Singularity can pull just knowing the URL. For example: |
| 80 | + |
| 81 | +```bash |
| 82 | +$ singularity pull https://github.com/singularityhub/singularity-deploy/releases/download/0.0.1/singularityhub-singularity-deploy.latest.sif |
| 83 | +``` |
| 84 | + |
| 85 | +However, the [singularity-hpc](singularity-hpc) tool (will be) designed to be able to parse and handle |
| 86 | +these container uris automatically. For the containers here, you could do: |
| 87 | + |
| 88 | +```bash |
| 89 | +$ shpc pull gh://singularityhub/singularity-deploy/0.0.1:latest |
| 90 | +$ shpc pull gh://singularityhub/singularity-deploy/0.0.1:salad |
| 91 | +$ shpc pull gh://singularityhub/singularity-deploy/0.0.1:pokemon |
| 92 | +``` |
| 93 | + |
| 94 | +or write the container URI into a registry entry: |
| 95 | + |
| 96 | +``` |
| 97 | +gh: singularityhub/singularity-deploy |
| 98 | +latest: |
| 99 | + latest: "0.0.1" |
| 100 | +tags: |
| 101 | + "latest": "0.0.1" |
| 102 | + "salad": "0.0.1" |
| 103 | + "pokemon": "0.0.1" |
| 104 | +maintainer: "@vsoch" |
| 105 | +url: https://github.com/singularityhub/singularity-deploy |
| 106 | +``` |
| 107 | + |
| 108 | +(This part is still under development!) |
0 commit comments