aboutsummaryrefslogtreecommitdiff
path: root/test/test_podman_build.sh
blob: 29b7354b1c96027e5d29026ac903d05260917662 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/usr/bin/env bash
#
# test_podman_build.sh
#
# Used to test 'podman build' functionality "by hand"
# until we're able to install Buildah in the Travis CI
# test system.
#
# Requires podman and Buildah to be installed on the
# system.  This needs to be run from the libpod
# directory after cloning the libpod repo.
#
# To run:
#   /bin/bash -v test_podman_build.sh
#

HOME=`pwd`

echo ########################################################
echo test "build-from-scratch"
echo ########################################################
  TARGET=scratch-image
  podman build -q=True -t $TARGET $HOME/test/build/from-scratch
  CID=$(buildah from $TARGET)
  buildah rm $CID
  podman build -q=False --build-arg HOME=/ --build-arg VERSION=0.1 -t $TARGET $HOME/test/build/from-scratch
  CID=$(buildah from $TARGET)
  buildah rm $CID
  podman build --quiet=True -t $TARGET $HOME/test/build/from-scratch
  CID=$(buildah from $TARGET)
  buildah rm $CID
  podman rmi -f $(podman images -q)
  podman images -q


echo ########################################################
echo test "build directory before other options create a tag"
echo ########################################################
TARGET=tagged-image
podman build $HOME/test/build/from-scratch --quiet=True -t $TARGET
podman images | grep tagged-image

echo ########################################################
echo test "build-preserve-subvolumes"
echo ########################################################
  TARGET=volume-image
  podman build -t $TARGET $HOME/test/build/preserve-volumes
  CID=$(buildah from $TARGET)
  ROOT=$(buildah mount $CID)
  test -s $ROOT/vol/subvol/subsubvol/subsubvolfile
  test -s $ROOT/vol/subvol/subvolfile
  test -s $ROOT/vol/volfile
  test -s $ROOT/vol/Dockerfile
  test -s $ROOT/vol/Dockerfile2
  test -s $ROOT/vol/anothervolfile
  buildah rm $CID
  podman rmi $(buildah --debug=false images -q)
  buildah --debug=false images -q

echo ########################################################
echo test "build-git-context"
echo ########################################################
  TARGET=giturl-image
  # Any repo should do, but this one is small and is FROM: scratch.
  GITREPO=git://github.com/projectatomic/nulecule-library
  podman build -t $TARGET "$GITREPO"
  CID=$(buildah from $TARGET)
  buildah rm $CID
  podman rmi $(buildah --debug=false images -q)
  podman images -q


echo ########################################################
echo test "build-github-context"
echo ########################################################
  TARGET=github-image
  # Any repo should do, but this one is small and is FROM: scratch.
  GITREPO=github.com/projectatomic/nulecule-library
  podman build -t $TARGET "$GITREPO"
  CID=$(buildah from $TARGET)
  buildah rm $CID
  buildah --debug=false images -q
  podman rmi $(buildah --debug=false images -q)
  podman images -q


echo ########################################################
echo test "build-additional-tags"
echo ########################################################
  TARGET=scratch-image
  TARGET2=another-scratch-image
  TARGET3=so-many-scratch-images
  podman build -t $TARGET -t $TARGET2 -t $TARGET3 -f $HOME/test/build/from-scratch/Dockerfile
  buildah --debug=false images
  CID=$(buildah from $TARGET)
  buildah rm $CID
  CID=$(buildah from library/$TARGET2)
  buildah rm $CID
  CID=$(buildah from $TARGET3:latest)
  buildah rm $CID
  podman rmi -f $(buildah --debug=false images -q)
  podman images -q


echo ########################################################
echo test "build-volume-perms"
echo ########################################################
  TARGET=volume-image
  podman build -t $TARGET $HOME/test/build/volume-perms
  CID=$(buildah from $TARGET)
  ROOT=$(buildah mount $CID)
  test -s $ROOT/vol/subvol/subvolfile
  stat -c %f $ROOT/vol/subvol
  #Output s/b 41ed
  buildah rm $CID
  podman rmi $(buildah --debug=false images -q)
  podman images -q


echo ########################################################
echo test "build-from-glob"
echo ########################################################
  TARGET=alpine-image
  podman build -t $TARGET -file Dockerfile2.glob $HOME/test/build/from-multiple-files
  CID=$(buildah from $TARGET)
  ROOT=$(buildah mount $CID)
  cmp $ROOT/Dockerfile1.alpine $HOME/test/build/from-multiple-files/Dockerfile1.alpine
  cmp $ROOT/Dockerfile2.withfrom $HOME/test/build/from-multiple-files/Dockerfile2.withfrom
  buildah rm $CID
  podman rmi $(buildah --debug=false images -q)
  podman images -q


echo ########################################################
echo test "build-from-multiple-files-one-from"
echo ########################################################
  TARGET=scratch-image
  podman build -t $TARGET -file $HOME/test/build/from-multiple-files/Dockerfile1.scratch -file $HOME/test/build/from-multiple-files/Dockerfile2.nofrom
  CID=$(buildah from $TARGET)
  ROOT=$(buildah mount $CID)
  cmp $ROOT/Dockerfile1 $HOME/test/build/from-multiple-files/Dockerfile1.scratch
  cmp $ROOT/Dockerfile2.nofrom $HOME/test/build/from-multiple-files/Dockerfile2.nofrom
  buildah rm $CID
  podman rmi $(buildah --debug=false images -q)
  buildah --debug=false images -q

  TARGET=alpine-image
  podman build -t $TARGET -file $HOME/test/build/from-multiple-files/Dockerfile1.alpine -file $HOME/test/build/from-multiple-files/Dockerfile2.nofrom
  CID=$(buildah from $TARGET)
  ROOT=$(buildah mount $CID)
  buildah rm $CID
  podman rmi $(buildah --debug=false images -q)
  buildah --debug=false images -q


echo ########################################################
echo test "build-from-multiple-files-two-froms"
echo ########################################################
  TARGET=scratch-image
  podman build -t $TARGET -file $HOME/test/build/from-multiple-files/Dockerfile1.scratch -file $HOME/test/build/from-multiple-files/Dockerfile2.withfrom
  CID=$(buildah from $TARGET)
  ROOT=$(buildah mount $CID)
  cmp $ROOT/Dockerfile1 $HOME/test/build/from-multiple-files/Dockerfile1.scratch
  cmp $ROOT/Dockerfile2.withfrom $HOME/test/build/from-multiple-files/Dockerfile2.withfrom
  test -s $ROOT/etc/passwd
  buildah rm $CID
  podman rmi $(buildah --debug=false images -q)
  buildah --debug=false images -q

  TARGET=alpine-image
  podman build -t $TARGET -file $HOME/test/build/from-multiple-files/Dockerfile1.alpine -file $HOME/test/build/from-multiple-files/Dockerfile2.withfrom
  CID=$(buildah from $TARGET)
  ROOT=$(buildah mount $CID)
  cmp $ROOT/Dockerfile1 $HOME/test/build/from-multiple-files/Dockerfile1.alpine
  cmp $ROOT/Dockerfile2.withfrom $HOME/test/build/from-multiple-files/Dockerfile2.withfrom
  test -s $ROOT/etc/passwd
  buildah rm $CID
  podman rmi $(buildah --debug=false images -q)
  buildah --debug=false images -q

echo ########################################################
echo test "build-from-multiple-files-two-froms" with "-f -"
echo ########################################################
  TARGET=scratch-image
  cat $HOME/test/build/from-multiple-files/Dockerfile1.alpine | podman build -t ${TARGET} -file - -file Dockerfile2.withfrom $HOME/test/build/from-multiple-files
  CID=$(buildah from $TARGET)
  ROOT=$(buildah mount $CID)
  cmp $ROOT/Dockerfile1 $HOME/test/build/from-multiple-files/Dockerfile1.alpine
  cmp $ROOT/Dockerfile2.withfrom $HOME/test/build/from-multiple-files/Dockerfile2.withfrom
  test -s $ROOT/etc/passwd
  buildah rm $CID
  podman rmi $(buildah --debug=false images -q)
  buildah --debug=false images -q

echo ########################################################
echo test "build with preprocessor"
echo ########################################################

  TARGET=alpine-image
  podman build -q -t ${TARGET} -f Decomposed.in $HOME/test/build/preprocess
  buildah --debug=false images
  CID=$(buildah from $TARGET)
  buildah rm $CID
  podman rmi $(buildah --debug=false images -q)
  buildah --debug=false images -q

echo ########################################################
echo test "build with priv'd RUN"
echo ########################################################

  TARGET=alpinepriv
  podman build -q -t ${TARGET} -f $HOME/test/build/run-privd $HOME/test/build/run-privd
  buildah --debug=false images
  CID=$(buildah from $TARGET)
  buildah rm $CID
  podman rmi $(buildah --debug=false images -q)
  buildah --debug=false images -q