Skip to content

Commit

Permalink
Merge pull request #4065 from flouthoc/tidy-demo
Browse files Browse the repository at this point in the history
[CI:DOCS] demo: use `buildah unshare` for `rootless` invocations
  • Loading branch information
openshift-ci[bot] authored Jun 23, 2022
2 parents 0a4fa3c + 404852b commit d8e9ca4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
10 changes: 9 additions & 1 deletion demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ This demo builds a container image from scratch. The container is going to injec

Please make sure you have installed Buildah and Podman. Also this demo uses Quay.io to push the image to that registry when it is completed. If you are not logged in then it will fail at that step and finish. If you wish to login to Quay.io before running the demo, then it will push to your repository successfully.

$ sudo buildah login quay.io
```bash
# Rootful session
$ sudo buildah login quay.io
#
# or
#
# Rootless session
$ buildah login quay.io
```

There are several variables you will want to set that are listed at the top of the script. The name for the container image, your quay.io username, your name, and the Fedora release number:

Expand Down
16 changes: 16 additions & 0 deletions demos/buildah-scratch-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@
# buildah login quay.io
# Set some of the variables below

#################
# is_rootless # Check if we run as normal user
#################
function is_rootless() {
[ "$(id -u)" -ne 0 ]
}

## Steps in this demo use pkg-managers like dnf and yum which
## must be invoked as root. Similarly `buildah mount` only work
## as root. The `buildah unshare` command switches your user
## session to root within the user namespace.
if is_rootless; then
buildah unshare $0
exit
fi

demoimg=myshdemo
quayuser=ipbabble
myname=WilliamHenry
Expand Down
16 changes: 16 additions & 0 deletions demos/buildah_multi_stage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
# Assumptions install buildah and podman
# Set some of the variables below


#################
# is_rootless # Check if we run as normal user
#################
function is_rootless() {
[ "$(id -u)" -ne 0 ]
}

## The `buildah mount` only work as root so use
## `buildah unshare` command which switches your
## user session to root within the user namespace.
if is_rootless; then
buildah unshare $0
exit
fi

demoimg=mymultidemo
quayuser=myquayuser
myname=MyName
Expand Down

0 comments on commit d8e9ca4

Please sign in to comment.