4545#
4646# A docker container. All commands on the host (using ./do or ./bin/*) are run in the context of a Docker image.
4747#
48+ # = podman
49+ #
50+ # A docker container run using Podman. All commands on the host (using ./do or ./bin/*) are run in the context of a Docker image.
51+ # Podman provides a Docker-compatible CLI.
52+ #
4853# = singularity
4954#
5055# An apptainer/singularity container. All commands on the host (using ./do or ./bin/*) are run in the context of an Apptainer/Singularity image.
6065# 1. devcontainer, if DEVCONTAINER_ENV is set in the environment
6166# 2. the type stored in .container-type
6267# 3. Docker, if DOCKER is set in the environment
63- # 4. Singularity, if SINGULARITY is set in the environment
64- # 5. The choice made by the user, which will be cached in .container-type
68+ # 4. Podman, if PODMAN is set in the environment
69+ # 5. Singularity, if SINGULARITY is set in the environment
70+ # 6. The choice made by the user, which will be cached in .container-type
6571if [ -v DEVCONTAINER_ENV ]; then
6672CONTAINER_TYPE=devcontainer
6773elif [ -f ${ROOT} /.container-type ]; then
6874CONTAINER_TYPE=` cat ${ROOT} /.container-type`
6975elif [ -v DOCKER ]; then
7076CONTAINER_TYPE=docker
77+ elif [ -v PODMAN ]; then
78+ CONTAINER_TYPE=podman
7179elif [ -v SINGULARITY ]; then
7280CONTAINER_TYPE=singularity
7381else
74- echo -e " UDB tools run in a container. Both Docker and Singularity/Apptainer are supported.\\ n\\ n1. Docker\\ n2. Singularity\\ n"
82+ echo -e " UDB tools run in a container. Docker, Podman, and Singularity/Apptainer are supported.\\ n\\ n1. Docker\\ n2. Podman \\ n3 . Singularity\\ n"
7583 while true ; do
76- echo " Which would you like to use? (1/2) "
84+ echo " Which would you like to use? (1/2/3 ) "
7785 read ans
7886 case $ans in
7987 [1]* ) CONTAINER_TYPE=docker; break ;;
80- [2]* ) CONTAINER_TYPE=singularity; break ;;
81- * ) echo -e " \\ nPlease answer 1 or 2." ;;
88+ [2]* ) CONTAINER_TYPE=podman; break ;;
89+ [3]* ) CONTAINER_TYPE=singularity; break ;;
90+ * ) echo -e " \\ nPlease answer 1, 2, or 3." ;;
8291 esac
8392 done
8493fi
8594
86- if [ " ${CONTAINER_TYPE} " != " docker" -a " ${CONTAINER_TYPE} " != " singularity" -a " ${CONTAINER_TYPE} " != " devcontainer" ]; then
95+ if [ " ${CONTAINER_TYPE} " != " docker" -a " ${CONTAINER_TYPE} " != " podman " -a " ${CONTAINER_TYPE} " != " singularity" -a " ${CONTAINER_TYPE} " != " devcontainer" ]; then
8796 echo " BAD CONTAINER TYPE: ${CONTAINER_TYPE} "
8897fi
8998
@@ -104,16 +113,22 @@ if [ -v GITHUB_ACTIONS ]; then
104113 # see https://github.com/lima-vm/lima/issues/2319
105114 sudo /bin/bash -c " echo \" kernel.apparmor_restrict_unprivileged_userns = 0\" >/etc/sysctl.d/99-userns.conf"
106115 sudo sysctl --system
107- elif [ " ${CONTAINER_TYPE} " == " docker" ]; then
108- if ! docker images riscvintl/udb:${CONTAINER_TAG} | grep -q udb ; then
116+ elif [ " ${CONTAINER_TYPE} " == " docker" -o " ${CONTAINER_TYPE} " == " podman " ]; then
117+ if ! ${CONTAINER_TYPE} images riscvintl/udb:${CONTAINER_TAG} | grep -q udb ; then
109118 # TODO: pull the image if it can be found
110- echo " Building Docker image..."
111- docker build -t riscvintl/udb:${CONTAINER_TAG} -f .devcontainer/Dockerfile .
119+ echo " Building ${CONTAINER_TYPE} image..."
120+ ${CONTAINER_TYPE} build -t riscvintl/udb:${CONTAINER_TAG} -f .devcontainer/Dockerfile .
121+ fi
122+ if [ ${CONTAINER_TYPE} == " podman" ]; then
123+ # Podman requires extra flags to handle SELinux
124+ SELINUX_LABEL=" :z"
125+ else
126+ SELINUX_LABEL=" "
112127 fi
113128 if [ -t 1 -a -t 0 ]; then
114- DOCKER_BASE= " docker run -it -v ${ROOT} :${ROOT} -w ${ROOT} riscvintl/udb:${CONTAINER_TAG} "
129+ CONTAINER_BASE= " ${CONTAINER_TYPE} run -it -v ${ROOT} :${ROOT}${SELINUX_LABEL } -w ${ROOT} riscvintl/udb:${CONTAINER_TAG} "
115130 else
116- DOCKER_BASE= " docker run -v ${ROOT} :${ROOT} -w ${ROOT} riscvintl/udb:${CONTAINER_TAG} "
131+ CONTAINER_BASE= " ${CONTAINER_TYPE} run -v ${ROOT} :${ROOT}${SELINUX_LABEL } -w ${ROOT} riscvintl/udb:${CONTAINER_TAG} "
117132 fi
118133elif [ " ${CONTAINER_TYPE} " == " singularity" ]; then
119134 CONTAINER_PATH=${ROOT} /.singularity/image-$CONTAINER_TAG .sif
142157
143158if [ " ${CONTAINER_TYPE} " == " devcontainer" ]; then
144159 RUN=" "
145- elif [ " ${CONTAINER_TYPE} " == " docker" ]; then
146- RUN=" ${DOCKER_BASE } "
160+ elif [ " ${CONTAINER_TYPE} " == " docker" -o " ${CONTAINER_TYPE} " == " podman " ]; then
161+ RUN=" ${CONTAINER_BASE } "
147162elif [ " ${CONTAINER_TYPE} " == " singularity" ]; then
148163 RUN=" singularity run ${HOME_OPT} ${CONTAINER_PATH} "
149164else
@@ -219,21 +234,21 @@ if [ "${CONTAINER_TYPE}" == "devcontainer" ]; then
219234 CLANG_FORMAT=" clang-format"
220235 CLANG_TIDY=" clang-tidy"
221236 MAKE=" make"
222- elif [ " ${CONTAINER_TYPE} " == " docker" ]; then
223- BUNDLE=" ${DOCKER_BASE } bundle"
224- RUBY=" ${DOCKER_BASE } bundle exec ruby"
225- RAKE=" ${DOCKER_BASE } bundle exec rake"
226- NPM=" ${DOCKER_BASE } npm"
227- NPX=" ${DOCKER_BASE } npx"
228- NODE=" ${DOCKER_BASE } node"
229- PYTHON=" ${DOCKER_BASE } ${ROOT} /.home/.venv/bin/python3"
230- PIP=" ${DOCKER_BASE } ${ROOT} /.home/.venv/bin/pip"
231- BASH=" ${DOCKER_BASE } bash"
232- GPP=" ${DOCKER_BASE } g++"
233- GDB=" ${DOCKER_BASE } gdb"
234- CLANG_FORMAT=" ${DOCKER_BASE } clang-format"
235- CLANG_TIDY=" ${DOCKER_BASE } clang-tidy"
236- MAKE=" ${DOCKER_BASE } make"
237+ elif [ " ${CONTAINER_TYPE} " == " docker" -o " ${CONTAINER_TYPE} " == " podman " ]; then
238+ BUNDLE=" ${CONTAINER_BASE } bundle"
239+ RUBY=" ${CONTAINER_BASE } bundle exec ruby"
240+ RAKE=" ${CONTAINER_BASE } bundle exec rake"
241+ NPM=" ${CONTAINER_BASE } npm"
242+ NPX=" ${CONTAINER_BASE } npx"
243+ NODE=" ${CONTAINER_BASE } node"
244+ PYTHON=" ${CONTAINER_BASE } ${ROOT} /.home/.venv/bin/python3"
245+ PIP=" ${CONTAINER_BASE } ${ROOT} /.home/.venv/bin/pip"
246+ BASH=" ${CONTAINER_BASE } bash"
247+ GPP=" ${CONTAINER_BASE } g++"
248+ GDB=" ${CONTAINER_BASE } gdb"
249+ CLANG_FORMAT=" ${CONTAINER_BASE } clang-format"
250+ CLANG_TIDY=" ${CONTAINER_BASE } clang-tidy"
251+ MAKE=" ${CONTAINER_BASE } make"
237252elif [ " ${CONTAINER_TYPE} " == " singularity" ]; then
238253 BUNDLE=" singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle"
239254 RUBY=" singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec ruby"
0 commit comments