-
Notifications
You must be signed in to change notification settings - Fork 0
/
container.ysh
executable file
·54 lines (40 loc) · 1.77 KB
/
container.ysh
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
#!/usr/bin/env ysh
if (len(ARGV) !== 3) {
echo "error: must provide exactly 3 parameters:"
echo " version, sha256 checksum, image tag"
exit 1
}
var version = $1
var checksum = $2
var image_tag = $3
# Instantiate a working container, build oils-for-unix
var working_container1 = $(buildah from docker.io/debian:stable-slim)
buildah add $working_container1 fetch-and-build.sh /root/
buildah run $working_container1 -- sh /root/fetch-and-build.sh $version $checksum
# Instantiate another working container
var working_container2 = $(buildah from docker.io/debian:stable-slim)
# Mount the filesystems of both working containers
var mnt1 = $(buildah mount $working_container1)
var mnt2 = $(buildah mount $working_container2)
# Copy the built binary and readline library from container 1 into container 2
# This is akin to a multi-stage build in Docker.
cp "${mnt1}/usr/local/bin/oils-for-unix" "${mnt2}/usr/local/bin"
cp "${mnt1}/usr/lib/x86_64-linux-gnu/libreadline.so.8" "${mnt2}/usr/lib/x86_64-linux-gnu/libreadline.so.8"
cp "${mnt1}/usr/lib/x86_64-linux-gnu/libreadline.so.8.2" "${mnt2}/usr/lib/x86_64-linux-gnu/libreadline.so.8.2"
# Set up the symlinks so osh and ysh are on the $PATH
buildah run $working_container2 -- ln -s /usr/local/bin/oils-for-unix /usr/local/bin/osh
buildah run $working_container2 -- ln -s /usr/local/bin/oils-for-unix /usr/local/bin/ysh
# Commit our image. It's ready to push after this.
buildah commit $working_container2 $image_tag
# Clean up.
buildah rm $working_container1
buildah rm $working_container2
# Run tests.
echo "Image committed: $image_tag"
echo "Running tests"
podman run --rm $image_tag osh -c 'echo hi from osh'
podman run --rm $image_tag ysh -c 'echo hi from ysh'
echo ""
echo "Things seem okay. Push with:"
echo ""
echo " buildah push $image_tag"