github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/test/system/build-testimage (about) 1 #!/bin/bash 2 # 3 # build-testimage - script for producing a test image for podman CI 4 # 5 # The idea is to have a small multi-purpose image that can be pulled once 6 # by system tests and used for as many tests as possible. This image 7 # should live on quay.io, should be small in size, and should include 8 # as many components as needed by system tests so they don't have to 9 # pull other images. 10 # 11 # Unfortunately, "small" is incompatible with "systemd" so tests 12 # still need a fedora image for that. 13 # 14 15 # Tag for this new image 16 YMD=$(date +%Y%m%d) 17 18 # git-relative path to this script 19 create_script=$(cd $(dirname $0) && git ls-files --full-name $(basename $0)) 20 if [ -z "$create_script" ]; then 21 create_script=$0 22 fi 23 24 # Creation timestamp, Zulu time 25 create_time_z=$(env TZ=UTC date +'%Y-%m-%dT%H:%M:%SZ') 26 27 set -ex 28 29 # We'll need to create a Containerfile plus various other files to add in 30 # 31 # Please document the reason for all flags, apk's, and anything non-obvious 32 tmpdir=$(mktemp -t -d $(basename $0).tmp.XXXXXXX) 33 cd $tmpdir 34 35 # 'image mount' test will confirm that this file exists and has our YMD tag 36 echo $YMD >testimage-id 37 38 # ...but set the timestamp on the file itself to a constant well-known 39 # value, for use by the 'run --tz' test. Date value chosen for nerdiness 40 # and because it's in the past. (Much as I'd love FFFFFFFF, we can't 41 # use any future date because of unpredictable leap second adjustments). 42 touch --date=@1600000000 testimage-id 43 44 # 'pod' test will use this for --infra-command 45 cat >pause <<EOF 46 #!/bin/sh 47 # 48 # Trivial little pause script, used in one of the pod tests 49 # 50 echo Confirmed: testimage pause invoked as \$0 51 while :; do 52 sleep 0.1 53 done 54 EOF 55 chmod 755 pause 56 57 # alpine because it's small and light and reliable 58 # - check for updates @ https://hub.docker.com/_/alpine 59 # busybox-extras provides httpd needed in 500-networking.bats 60 cat >Containerfile <<EOF 61 FROM docker.io/library/alpine:3.12.0 62 RUN apk add busybox-extras 63 ADD testimage-id pause /home/podman/ 64 LABEL created_by=$create_script 65 LABEL created_at=$create_time_z 66 WORKDIR /home/podman 67 CMD ["/bin/echo", "This container is intended for podman CI testing"] 68 EOF 69 70 # --squash-all : needed by 'tree' test in 070-build.bats 71 podman rmi -f testimage &> /dev/null || true 72 podman build --squash-all -t testimage . 73 74 # Clean up 75 cd /tmp 76 rm -rf $tmpdir 77 78 # Tag and push to quay. 79 podman tag testimage quay.io/libpod/testimage:$YMD 80 podman push quay.io/libpod/testimage:$YMD 81 82 # Side note: there should always be a testimage tagged ':00000000' 83 # (eight zeroes) in the same location; this is used by tests which 84 # need to pull a non-locally-cached image. This image will rarely 85 # if ever need to change, nor in fact does it even have to be a 86 # copy of this testimage since all we use it for is 'true'. 87 # 88 # As of 2020-09-02 it is simply busybox, because it is super small: 89 # 90 # podman pull docker.io/library/busybox:1.32.0 91 # podman tag docker.io/library/busybox:1.32.0 \ 92 # quay.io/libpod/testimage:00000000 93 # podman push quay.io/libpod/testimage:00000000 94 #