{"id":22599653,"url":"https://github.com/singularityhub/circle-ci-sregistry","last_synced_at":"2025-08-01T04:18:13.457Z","repository":{"id":92775660,"uuid":"169643824","full_name":"singularityhub/circle-ci-sregistry","owner":"singularityhub","description":"An example repository to deploy multiple containers to a Singularity Registry Server from CircleCI","archived":false,"fork":false,"pushed_at":"2019-02-20T07:43:46.000Z","size":137,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T19:50:06.682Z","etag":null,"topics":["builder-repository","singularity","sregistry"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/singularityhub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-07T21:15:34.000Z","updated_at":"2019-02-20T07:43:47.000Z","dependencies_parsed_at":"2023-04-21T09:35:12.064Z","dependency_job_id":null,"html_url":"https://github.com/singularityhub/circle-ci-sregistry","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/singularityhub/circle-ci-sregistry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singularityhub%2Fcircle-ci-sregistry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singularityhub%2Fcircle-ci-sregistry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singularityhub%2Fcircle-ci-sregistry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singularityhub%2Fcircle-ci-sregistry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/singularityhub","download_url":"https://codeload.github.com/singularityhub/circle-ci-sregistry/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singularityhub%2Fcircle-ci-sregistry/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265529119,"owners_count":23782825,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["builder-repository","singularity","sregistry"],"created_at":"2024-12-08T11:11:00.972Z","updated_at":"2025-07-16T18:07:17.441Z","avatar_url":"https://github.com/singularityhub.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Singularity Builder Circle-CI\n\n![.circleci/sregistry-circle.png](.circleci/sregistry-circle.png)\n\nThis is a simple example of how you can achieve:\n\n - version control of your recipes\n - versioning to include image hash *and* commit id\n - build of associated container and\n - push to a storage endpoint\n\nfor a reproducible build workflow. Specifically, this example will use a *single repository*\nas a base to build *multiple containers* and push to a shared [Singularity Registry Server](https://www.github.com/singularityhub/sregistry) based on the namespace organization.\n\n**Why should this be managed via Github?**\n\nGithub, by way of easy integration with continuous integration, is an easy way\nto have a workflow set up where multiple people can collaborate on a container recipe,\nthe recipe can be tested (with whatever testing you need), discussed in pull requests,\nand then finally pushed to your storage of choice or Singularity Registry. \nImportantly, you don't need to give your entire team manager permissions \nto the registry. An encrypted credential that only is accessible to \nadministrators can do the push upon merge of a discussed change.\n\n**Why should I use this instead of a service?**\n\nYou could use a remote builder, but if you do the build in a continuous integration\nservice you get complete control over it. This means everything from the version of\nSingularity to use, to the tests that you run for your container. You have a lot more\nfreedom in the rate of building, and organization of your repository, because it's you\nthat writes the configuration. Although the default would work for most, you can \nedit the build, setup, and circle configuration file in the \n[.circleci](.circleci) folder to fit your needs.\n\n## Quick Start\n\nThe [circle-ci-sregistry](https://github.com/singularityhub/circle-ci-sregistry) repository is \nan example repository that will allow you to store multiple recipes within, and then deploy\nto a [Singularity Registey Server](https://www.github.com/singularityhub/sregistry).\nWe use CircleCI to build and push to your Singularity Registry. You have the freedom\nto store as many recipes in one repository as you please, with the understanding that one\nrepository maps to one builder on CircleCI (in terms of time allowed). However, you should\nalso realize that since the build and deploy happens with pull requests, you can have the bulids\ngoing in parallel (up to the time limit, of course). You are also free to have multiple repositories\nto deploy separate containers, but you would then need to ensure that the namespaces (the folders \nnamed inside that map to collection names) do not overlap.\n\n### 1. Setup\n\nTo deploy this template for your registry you can:\n\n - Fork or download [singularityhub/circle-ci-sregistry](https://www.github.com/singularityhub/circle-ci-sregistry) to your own GitHub account. Since the container namespace comes from the folders within, the name of the repository itself is not incredibly important. \n - [Connect your repository](https://circleci.com/docs/2.0/getting-started/#setting-up-your-build-on-circleci) to CircleCI\n\n### 2. Adding Containers\n\nHow does building work? Each folder represents a namespace. For example, the folder `vanessa/greeting` maps to a container collection `vanessa/greeting`. \n\n#### Add a New Container\n\nThis means that to add a new container collection namespace, just create a folder for it.\n\n```bash\n$ mkdir -p vanessa/greeting\n```\n\nHow do tags work? The tags within the folder correspond to the tags for the container namespace. For example, here\nis how to create the tag \"pancakes\" for the container collection \"vanessa/greeting.\" \n\n```bash\n$ touch vanessa/greeting/Singularity.pancakes\n```\n\nThe Singularity file without any tags maps to the tag \"latest\"\n\n```bash\n$ touch vanessa/greeting/Singularity\n```\n\nThat's it! Write your recipe there, and then open a pull request to build the container. Once the container is built, you need to approve the Hold in the continuous integration, and then the container will be pushed.\nMerging (or generally pushing to master) doesn't do any deployment. All deployments must happen\nthrough this pull request and approve process.\n\n#### Freezing a Container\n\nIf you don't want a container collection to build, just put a .frozen file in the collection folder.\nIf you want to freeze the entire collection namespace, just put the .frozen file:\n\n```bash\ntouch vanessa/greeting/.frozen\n```\n\nIf you want to freeze a particular container, add an equivalently named empty file with frozen as\nan extension.\n\n```bash\ntouch vanessa/greeting/Singularity.pancakes.frozen\n```\n\nIt's a very manual way of doing it, but importantly, the status of your building is\nreflected in the repository (version controlled!).\n\n#### Custom Build for a Container\n\nIf you want to custom build a container, just add a build.sh file to the directory with the recipe.\nIt will be used instead of the default build.sh provided with the repository.\n\n### 3. Connect to CircleCI\n\nIf you go to your [Circle Dashboard](https://circleci.com/dashboard) you can usually select a Github organization (or user) and then the repository, and then click the toggle button to activate it to build on commit --\u003e push.\n\n### 4. CircleCI Environment\n\nIn order to communicate with your Singularity Registry Server, you should generate a\ntoken (a credential to push) in your $HOME/.sregistry file. Then you should add the entire\ncontents of this file to an encrypted CircleCI environment variable (just copy paste in the entire thing)\n\n```\ncat $HOME/.sregistry\n```\n\nwrite this to the environment variable `SREGISTRY_CREDENTIALS` in CircleCI.\nIf you don't define this variable, the builds will happen, but the deploy will\nbe skipped.\n \nThat should be it! You should then open pull requests to build containers,\nand then approve the Holds in the CircleCI interface to push to your registry. For example,\nhere is the workflow view right after a hold was approved (notice that the deploy step is\nrunning):\n\n![.circleci/hold.png](.circleci/hold.png)\n\nAnd here is when the deploy is done!\n\n![.circleci/deploy.png](.circleci/deploy.png)\n\nYou can check what will be deployed (and the command used) in the Build step, it will\nlook something like this:\n\n```bash\nSREGISTRY_CLIENT=registry sregistry push --name \"vanessa/greeting:latest\" \"/home/circleci/repo/vanessa/greeting/Singularity.sif\"\nSREGISTRY_CLIENT=registry sregistry push --name \"vanessa/greeting:tag\" \"/home/circleci/repo/vanessa/greeting/Singularity.tag.sif\"\n```\n\nNotice how the container namespace reflects the folder organization provided in\nthe repository here!\n\nIf you are interested in learning more about CircleCI (extra features!) continue\nreading below.\n\n\n### Extra: Get to Know CircleCi\n\nAs we are working with [Circle CI](https://www.circleci.com), here are some other features\nthat might be of interest.\n\n - Circle offers [scheduled builds](https://support.circleci.com/hc/en-us/articles/115015481128-Scheduling-jobs-cron-for-builds-).\n - CircleCI also offers [GPU Builders](https://circleci.com/docs/enterprise/gpu-configuration/) if you want/need that sort of thing.\n - If you don't want to use the [sregistry](https://singularityhub.github.io/sregistry-cli) to push to Google Storage, Drive, Globus, Dropbox, or your personal Singularity Registry, CircleCI will upload your artifacts directly to your [deployment](https://circleci.com/docs/2.0/deployment-integrations/#section=deployment) location of choice.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingularityhub%2Fcircle-ci-sregistry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsingularityhub%2Fcircle-ci-sregistry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingularityhub%2Fcircle-ci-sregistry/lists"}