github.com/AbhinandanKurakure/podman/v3@v3.4.10/test/test_podman_build.sh (about) 1 #!/usr/bin/env bash 2 # 3 # test_podman_build.sh 4 # 5 # Used to test 'podman build' functionality "by hand" 6 # until we're able to install Buildah in the Travis CI 7 # test system. 8 # 9 # Requires podman and Buildah to be installed on the 10 # system. This needs to be run from the libpod 11 # directory after cloning the libpod repo. 12 # 13 # To run: 14 # /bin/bash -v test_podman_build.sh 15 # 16 17 HOME=`pwd` 18 19 echo ######################################################## 20 echo test "build-from-scratch" 21 echo ######################################################## 22 TARGET=scratch-image 23 podman build -q=True -t $TARGET $HOME/test/build/from-scratch 24 CID=$(buildah from $TARGET) 25 buildah rm $CID 26 podman build -q=False --build-arg HOME=/ --build-arg VERSION=0.1 -t $TARGET $HOME/test/build/from-scratch 27 CID=$(buildah from $TARGET) 28 buildah rm $CID 29 podman build --quiet=True -t $TARGET $HOME/test/build/from-scratch 30 CID=$(buildah from $TARGET) 31 buildah rm $CID 32 podman rmi -f $(podman images -q) 33 podman images -q 34 35 36 echo ######################################################## 37 echo test "build directory before other options create a tag" 38 echo ######################################################## 39 TARGET=tagged-image 40 podman build $HOME/test/build/from-scratch --quiet=True -t $TARGET 41 podman images | grep tagged-image 42 43 echo ######################################################## 44 echo test "build-preserve-subvolumes" 45 echo ######################################################## 46 TARGET=volume-image 47 podman build -t $TARGET $HOME/test/build/preserve-volumes 48 CID=$(buildah from $TARGET) 49 ROOT=$(buildah mount $CID) 50 test -s $ROOT/vol/subvol/subsubvol/subsubvolfile 51 test -s $ROOT/vol/subvol/subvolfile 52 test -s $ROOT/vol/volfile 53 test -s $ROOT/vol/Dockerfile 54 test -s $ROOT/vol/Dockerfile2 55 test -s $ROOT/vol/anothervolfile 56 buildah rm $CID 57 podman rmi $(buildah --debug=false images -q) 58 buildah --debug=false images -q 59 60 echo ######################################################## 61 echo test "build-git-context" 62 echo ######################################################## 63 TARGET=giturl-image 64 # Any repo should do, but this one is small and is FROM: scratch. 65 GITREPO=git://github.com/projectatomic/nulecule-library 66 podman build -t $TARGET "$GITREPO" 67 CID=$(buildah from $TARGET) 68 buildah rm $CID 69 podman rmi $(buildah --debug=false images -q) 70 podman images -q 71 72 73 echo ######################################################## 74 echo test "build-github-context" 75 echo ######################################################## 76 TARGET=github-image 77 # Any repo should do, but this one is small and is FROM: scratch. 78 GITREPO=github.com/projectatomic/nulecule-library 79 podman build -t $TARGET "$GITREPO" 80 CID=$(buildah from $TARGET) 81 buildah rm $CID 82 buildah --debug=false images -q 83 podman rmi $(buildah --debug=false images -q) 84 podman images -q 85 86 87 echo ######################################################## 88 echo test "build-additional-tags" 89 echo ######################################################## 90 TARGET=scratch-image 91 TARGET2=another-scratch-image 92 TARGET3=so-many-scratch-images 93 podman build -t $TARGET -t $TARGET2 -t $TARGET3 -f $HOME/test/build/from-scratch/Dockerfile 94 buildah --debug=false images 95 CID=$(buildah from $TARGET) 96 buildah rm $CID 97 CID=$(buildah from library/$TARGET2) 98 buildah rm $CID 99 CID=$(buildah from $TARGET3:latest) 100 buildah rm $CID 101 podman rmi -f $(buildah --debug=false images -q) 102 podman images -q 103 104 105 echo ######################################################## 106 echo test "build-volume-perms" 107 echo ######################################################## 108 TARGET=volume-image 109 podman build -t $TARGET $HOME/test/build/volume-perms 110 CID=$(buildah from $TARGET) 111 ROOT=$(buildah mount $CID) 112 test -s $ROOT/vol/subvol/subvolfile 113 stat -c %f $ROOT/vol/subvol 114 #Output s/b 41ed 115 buildah rm $CID 116 podman rmi $(buildah --debug=false images -q) 117 podman images -q 118 119 120 echo ######################################################## 121 echo test "build-from-glob" 122 echo ######################################################## 123 TARGET=alpine-image 124 podman build -t $TARGET -file Dockerfile2.glob $HOME/test/build/from-multiple-files 125 CID=$(buildah from $TARGET) 126 ROOT=$(buildah mount $CID) 127 cmp $ROOT/Dockerfile1.alpine $HOME/test/build/from-multiple-files/Dockerfile1.alpine 128 cmp $ROOT/Dockerfile2.withfrom $HOME/test/build/from-multiple-files/Dockerfile2.withfrom 129 buildah rm $CID 130 podman rmi $(buildah --debug=false images -q) 131 podman images -q 132 133 134 echo ######################################################## 135 echo test "build-from-multiple-files-one-from" 136 echo ######################################################## 137 TARGET=scratch-image 138 podman build -t $TARGET -file $HOME/test/build/from-multiple-files/Dockerfile1.scratch -file $HOME/test/build/from-multiple-files/Dockerfile2.nofrom 139 CID=$(buildah from $TARGET) 140 ROOT=$(buildah mount $CID) 141 cmp $ROOT/Dockerfile1 $HOME/test/build/from-multiple-files/Dockerfile1.scratch 142 cmp $ROOT/Dockerfile2.nofrom $HOME/test/build/from-multiple-files/Dockerfile2.nofrom 143 buildah rm $CID 144 podman rmi $(buildah --debug=false images -q) 145 buildah --debug=false images -q 146 147 TARGET=alpine-image 148 podman build -t $TARGET -file $HOME/test/build/from-multiple-files/Dockerfile1.alpine -file $HOME/test/build/from-multiple-files/Dockerfile2.nofrom 149 CID=$(buildah from $TARGET) 150 ROOT=$(buildah mount $CID) 151 buildah rm $CID 152 podman rmi $(buildah --debug=false images -q) 153 buildah --debug=false images -q 154 155 156 echo ######################################################## 157 echo test "build-from-multiple-files-two-froms" 158 echo ######################################################## 159 TARGET=scratch-image 160 podman build -t $TARGET -file $HOME/test/build/from-multiple-files/Dockerfile1.scratch -file $HOME/test/build/from-multiple-files/Dockerfile2.withfrom 161 CID=$(buildah from $TARGET) 162 ROOT=$(buildah mount $CID) 163 cmp $ROOT/Dockerfile1 $HOME/test/build/from-multiple-files/Dockerfile1.scratch 164 cmp $ROOT/Dockerfile2.withfrom $HOME/test/build/from-multiple-files/Dockerfile2.withfrom 165 test -s $ROOT/etc/passwd 166 buildah rm $CID 167 podman rmi $(buildah --debug=false images -q) 168 buildah --debug=false images -q 169 170 TARGET=alpine-image 171 podman build -t $TARGET -file $HOME/test/build/from-multiple-files/Dockerfile1.alpine -file $HOME/test/build/from-multiple-files/Dockerfile2.withfrom 172 CID=$(buildah from $TARGET) 173 ROOT=$(buildah mount $CID) 174 cmp $ROOT/Dockerfile1 $HOME/test/build/from-multiple-files/Dockerfile1.alpine 175 cmp $ROOT/Dockerfile2.withfrom $HOME/test/build/from-multiple-files/Dockerfile2.withfrom 176 test -s $ROOT/etc/passwd 177 buildah rm $CID 178 podman rmi $(buildah --debug=false images -q) 179 buildah --debug=false images -q 180 181 echo ######################################################## 182 echo test "build-from-multiple-files-two-froms" with "-f -" 183 echo ######################################################## 184 TARGET=scratch-image 185 cat $HOME/test/build/from-multiple-files/Dockerfile1.alpine | podman build -t ${TARGET} -file - -file Dockerfile2.withfrom $HOME/test/build/from-multiple-files 186 CID=$(buildah from $TARGET) 187 ROOT=$(buildah mount $CID) 188 cmp $ROOT/Dockerfile1 $HOME/test/build/from-multiple-files/Dockerfile1.alpine 189 cmp $ROOT/Dockerfile2.withfrom $HOME/test/build/from-multiple-files/Dockerfile2.withfrom 190 test -s $ROOT/etc/passwd 191 buildah rm $CID 192 podman rmi $(buildah --debug=false images -q) 193 buildah --debug=false images -q 194 195 echo ######################################################## 196 echo test "build with preprocessor" 197 echo ######################################################## 198 199 TARGET=alpine-image 200 podman build -q -t ${TARGET} -f Decomposed.in $HOME/test/build/preprocess 201 buildah --debug=false images 202 CID=$(buildah from $TARGET) 203 buildah rm $CID 204 podman rmi $(buildah --debug=false images -q) 205 buildah --debug=false images -q 206 207 echo ######################################################## 208 echo test "build with priv'd RUN" 209 echo ######################################################## 210 211 TARGET=alpinepriv 212 podman build -q -t ${TARGET} -f $HOME/test/build/run-privd $HOME/test/build/run-privd 213 buildah --debug=false images 214 CID=$(buildah from $TARGET) 215 buildah rm $CID 216 podman rmi $(buildah --debug=false images -q) 217 buildah --debug=false images -q