aboutsummaryrefslogtreecommitdiff
path: root/test/test_podman_build.sh
blob: a595e52c0097cbddcfa63765a2bad83e9f73d870 (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
#!/bin/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`

########
# test "build-from-scratch"
########
  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


########
# test "build-preserve-subvolumes"
########
  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

########
# test "build-git-context"
########
  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


########
# test "build-github-context"
########
  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


########
# test "build-additional-tags"
########
  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


########
# test "build-volume-perms"
########
  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


########
# test "build-from-glob"
########
  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


########
# test "build-from-multiple-files-one-from"
########
  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


########
# test "build-from-multiple-files-two-froms"
########
  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