├── images └── apptainer_logo.png ├── .gitignore ├── tests ├── interpreter │ ├── interpreter.def │ └── interpret.py ├── server │ └── server.def └── simulation │ ├── simulation.def │ └── sim.r ├── tox.ini ├── README.md ├── snap └── snapcraft.yaml └── LICENSE /images/apptainer_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/canonical/apptainer/main/images/apptainer_logo.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Snap 2 | /parts/ 3 | /stage/ 4 | /prime/ 5 | *.snap 6 | .snapcraft 7 | __pycache__ 8 | *.pyc 9 | *_source.tar.bz2 10 | snap/.snapcraft 11 | /.tox/ 12 | 13 | # PyCharm 14 | /.idea/ 15 | -------------------------------------------------------------------------------- /tests/interpreter/interpreter.def: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Canonical Ltd. 2 | # See LICENSE file for licensing details. 3 | 4 | Bootstrap: docker 5 | From: python:3.11.0-slim-buster 6 | 7 | %post 8 | python3 -m pip install tabulate emoji 9 | 10 | %help 11 | A test for checking that the Apptainer snap can execute commands 12 | and Python source files inside a container. 13 | -------------------------------------------------------------------------------- /tests/server/server.def: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Canonical Ltd. 2 | # See LICENSE file for licensing details. 3 | 4 | Bootstrap: docker 5 | From: python:3.11.0-slim-buster 6 | 7 | %startscript 8 | python3 -m http.server --directory /opt 9 | 10 | %post 11 | mkdir -p /opt 12 | echo "Hello there" > /opt/test.txt 13 | 14 | %help 15 | A test for checking that the Apptainer snap can run containers as services. 16 | -------------------------------------------------------------------------------- /tests/simulation/simulation.def: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Canonical Ltd. 2 | # See LICENSE file for licensing details. 3 | 4 | Bootstrap: docker 5 | From: r-base:4.2.2 6 | 7 | %runscript 8 | Rscript /opt/sim.r 9 | 10 | %files 11 | sim.r /opt/sim.r 12 | 13 | %post 14 | Rscript -e "install.packages('reshape2', repos='http://lib.stat.cmu.edu/R/CRAN/')" 15 | Rscript -e "install.packages('ggplot2', repos='http://lib.stat.cmu.edu/R/CRAN/')" 16 | 17 | %help 18 | A test for checking that the Apptainer can run pre-bundled files. -------------------------------------------------------------------------------- /tests/interpreter/interpret.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2022 Canonical Ltd. 3 | # See LICENSE file for licensing details. 4 | 5 | """Test that certain packages are available though Apptainer.""" 6 | 7 | from emoji import emojize 8 | from tabulate import tabulate 9 | from urllib.request import urlopen 10 | 11 | 12 | if (page := urlopen("https://canonical.com")).status == 200: 13 | print(tabulate( 14 | [[page.status, f"Able to connect to canonical.com {emojize(':thumbs_up:')}"]], 15 | headers=["Status", "Message"] 16 | )) 17 | else: 18 | print(tabulate( 19 | [[page.status, f"Cannot connect to canonical.com {emojize(':thumbs_down:')}"]], 20 | headers=["Status", "Message"] 21 | )) 22 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Canonical Ltd. 2 | # See LICENSE file for licensing details. 3 | 4 | [tox] 5 | envlist = snap, install 6 | skipsdist = True 7 | 8 | [testenv] 9 | setenv = 10 | PATH = /snap/bin:{env:PATH} 11 | whitelist_externals = 12 | sudo 13 | bash 14 | rm 15 | /usr/bin/snap 16 | /snap/bin/snapcraft 17 | 18 | [testenv:snap] 19 | description = Build Apptainer snap package using LXD as build provider. 20 | commands = 21 | snapcraft 22 | 23 | [testenv:install] 24 | description = Install locally built, unsigned snap on system. 25 | commands = 26 | bash -c "sudo snap install {toxinidir}/apptainer_*_amd64.snap --dangerous --classic" 27 | 28 | [testenv:clean] 29 | description = Purge apptainer system. 30 | commands = 31 | sudo snap remove --purge apptainer 32 | bash -c "rm -f {toxinidir}/apptainer_*_amd64.snap" 33 | snapcraft clean 34 | -------------------------------------------------------------------------------- /tests/simulation/sim.r: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env Rscript 2 | # Copyright 2022 Canonical Ltd. 3 | # See LICENSE file for licensing details. 4 | 5 | # Simple graph plotter program 6 | # Load ggplot2, reshape2, and lattice libraries 7 | library(ggplot2) 8 | library(reshape2) 9 | library(lattice) 10 | 11 | # First make plots of Lake Huron using a 12 | # simple plot function. Save to .png file. 13 | png(filename = "huron_type_l.png") 14 | plot(LakeHuron, type="l", main = "type=\"l\"") 15 | dev.off() 16 | 17 | png(filename = "huron_type_p.png") 18 | plot(LakeHuron, type="p", main = "type=\"p\"") 19 | dev.off() 20 | 21 | png(filename = "huron_type_b.png") 22 | plot(LakeHuron, type="b", main = "type=\"b\"") 23 | dev.off() 24 | 25 | # Now make a plot using reshape2 and lattice 26 | mlongley <- melt(longley, id.vars = "Year") 27 | my.plot <- xyplot(value ~ Year | variable, data = mlongley, 28 | layout = c(6, 1), 29 | par.strip.text = list(cex = 0.5), 30 | scales = list(cex = 0.5)) 31 | trellis.device(device = "png", filename="longley_xyplot.png") 32 | print(my.plot) 33 | dev.off() 34 | 35 | # Now make some plots using ggplot 36 | png(filename = "fancy_graph_1.png") 37 | gplot1 <- ggplot(faithful, aes(x = eruptions, y = waiting)) + 38 | geom_point() + 39 | stat_smooth() 40 | print(gplot1) 41 | dev.off() 42 | 43 | quakes.agg <- aggregate(mag ~ round(depth, -1), data = quakes, FUN = length) 44 | names(quakes.agg) <- c("depth", "mag") 45 | 46 | png(filename = "fancy_graph_2.png") 47 | gplot2 <- ggplot(quakes.agg, aes(x = depth, y = mag)) + 48 | geom_bar(stat = "identity") 49 | print(gplot2) 50 | dev.off() 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Apptainer Logo 3 |
4 |
5 | Apptainer 6 |

7 | 8 |

9 | This is the snap package for Apptainer, 10 | an open-source container system for High-Performance Computing. 11 |

12 | 13 | > The upstream Apptainer repository can be 14 | > located [here](https://github.com/apptainer/apptainer) 15 | 16 | ## Installation 17 | 18 | ### Install from the Snap Store 19 | 20 | > The Apptainer snap package has not been released to the Snap Store yet. 21 | 22 | ### Building the snap yourself 23 | 24 | Use the following commands to build the Apptainer snap package locally. 25 | It is assumed that you already have `snapd` installed on your system. If not, you 26 | can find instructions for installing `snapd` on your system 27 | [here](https://snapcraft.io/docs/installing-snapd): 28 | 29 | 1. Install `tox` and `snapcraft` on your system 30 | 31 | ```commandline 32 | sudo apt install tox 33 | sudo snap install snapcraft --channel=edge --classic 34 | ``` 35 | 36 | 2. Clone the repository 37 | 38 | ```commandline 39 | git clone https://github.com/canonical/apptainer 40 | ``` 41 | 42 | 3. Use `tox` to build the snap 43 | 44 | ```commandline 45 | tox -e snap 46 | ``` 47 | 48 | 4. Install 49 | 50 | ```commandline 51 | tox -e install 52 | ``` 53 | 54 | ## Usage 55 | 56 | The Apptainer snap is intended to be one-for-one compatible with the upstream Apptainer; 57 | therefore, you can refer to the [official Apptainer documentation](https://apptainer.org/docs/user/main/) 58 | for usage information. 59 | 60 | -------------------------------------------------------------------------------- /snap/snapcraft.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Canonical Ltd. 2 | # See LICENSE file for licensing details. 3 | 4 | name: apptainer 5 | version: 1.1.3 6 | license: BSD-3-Clause-LBNL 7 | summary: An open-source container system for High-Performance Computing. 8 | description: | 9 | Apptainer is the most widely used container system for High-Performance 10 | Computing. It is designed to execute applications at bare-metal performance 11 | while being secure, portable, and 100% reproducible. Apptainer is an 12 | open-source project with a friendly community of developers and users. 13 | The user base continues to expand, with Apptainer now used across industry 14 | and academia in many areas of work. 15 | 16 | base: core22 17 | grade: devel 18 | confinement: classic 19 | compression: lzo 20 | 21 | architectures: 22 | - build-on: amd64 23 | 24 | parts: 25 | # Need to install newuidmap and newgidmap from source. 26 | # This needs to be done because snapcraft automatically 27 | # strips out the suid bit. 28 | shadow: 29 | plugin: dump 30 | source: https://github.com/shadow-maint/shadow/releases/download/4.13/shadow-4.13.tar.gz 31 | source-type: tar 32 | build-attributes: 33 | - enable-patchelf 34 | build-packages: 35 | - build-essential 36 | override-build: | 37 | craftctl default 38 | cd $CRAFT_PART_SRC 39 | ./configure --prefix=$CRAFT_PART_INSTALL/usr 40 | make && make install 41 | 42 | apptainer: 43 | after: [shadow] 44 | plugin: dump 45 | source: https://github.com/apptainer/apptainer.git 46 | source-tag: v1.1.3 47 | source-type: git 48 | build-attributes: 49 | - enable-patchelf 50 | build-packages: 51 | - build-essential 52 | - libseccomp-dev 53 | - pkg-config 54 | - squashfs-tools 55 | - squashfuse 56 | - fuse2fs 57 | - fuse-overlayfs 58 | - fakeroot 59 | - cryptsetup 60 | - curl 61 | - wget 62 | - golang 63 | stage-packages: 64 | - libseccomp-dev 65 | - pkg-config 66 | - squashfs-tools 67 | - squashfuse 68 | - fuse2fs 69 | - fuse-overlayfs 70 | - fakeroot 71 | - cryptsetup 72 | - curl 73 | - wget 74 | - golang 75 | override-build: | 76 | craftctl default 77 | cd $CRAFT_PART_SRC 78 | ./mconfig --prefix=$CRAFT_PART_INSTALL 79 | make -C builddir && make -C builddir install 80 | 81 | # Remove extraneous files and directories to trim snap size. 82 | cleanup: 83 | after: [apptainer] 84 | plugin: nil 85 | override-prime: | 86 | set -eux 87 | cd $CRAFT_PRIME 88 | rm -rf \ 89 | .git .gitignore *.md builddir cmd dist docs e2e \ 90 | examples go.mod go.sum internal \ 91 | makeit mconfig mlocal pkg scripts tools 92 | sed -i 's;#.binary path =;binary path = /snap/apptainer/current/bin:/snap/apptainer/current/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin;g' etc/apptainer/apptainer.conf 93 | chmod u+s usr/bin/squashfuse 94 | chmod u+s usr/bin/newuidmap 95 | chmod u+s usr/bin/newgidmap 96 | 97 | apps: 98 | apptainer: 99 | command: bin/apptainer 100 | 101 | singularity: 102 | command: bin/singularity 103 | 104 | run-singularity: 105 | command: bin/run-singularity 106 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------