Skip to content

Commit c873067

Browse files
committed
ci: use a build arg to set base image as alpine:3.7
1 parent f61609e commit c873067

File tree

9 files changed

+29
-19
lines changed

9 files changed

+29
-19
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.swp
22
*~
33
**/hooktftp
4+
ci/vars

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ Output from `ci/test` resembles:
197197
[RUN] docker_rm fixtures
198198

199199
===> Create data container in which to download test files.
200-
[RUN] docker create --name downloads -v /home/user alpine:3.7 true
200+
[RUN] docker create --name downloads -v /home/user ${BASE_IMAGE} true
201201
19d787a81fa8cc3d68fdd97f0d7fa85d2d3f95fadcd144e52f47aafda74fb763
202-
[RUN] docker run --rm --volumes-from downloads alpine:3.7 chown -R 1000:1000 /home/user
202+
[RUN] docker run --rm --volumes-from downloads ${BASE_IMAGE} chown -R 1000:1000 /home/user
203203

204204
===> Create data container for fixtures.
205205
[RUN] docker create --name fixtures hooktftp-fixtures true

Diff for: ci/build

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
#!/bin/bash
22
set -e
33

4+
cat >ci/vars <<EOF
5+
BASE_IMAGE='alpine:3.7'
6+
VCS_REF="$(git rev-parse --short HEAD)"
7+
TAG="$(date +%Y%m%dT%H%M)-git-\${VCS_REF}"
8+
EOF
9+
410
. ci/functions
11+
. ci/vars
512

613
info "Build a tiny runtime image with hooktftp static binary."
714
pushd src/alpine/builder
8-
run docker build --rm -t hooktftp-runtime .
15+
run docker build --rm --build-arg BASE_IMAGE="${BASE_IMAGE}" -t hooktftp-runtime .
916
popd
1017

1118
info "Build a fixtures images that we use to test."
1219
run docker build --rm -t hooktftp-fixtures fixtures/
1320

1421
info "Build a tiny tftp client image that we use to test."
1522
pushd src/alpine/client
16-
run docker build --rm -t tftp .
23+
run docker build --rm --build-arg BASE_IMAGE="${BASE_IMAGE}" -t tftp .
1724
popd
1825

1926
info "Show image sizes."

Diff for: ci/publish

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
set -eEu
33
set -o pipefail
44

5-
VCS_REF="$(git rev-parse --short HEAD)"
6-
readonly VCS_REF
7-
8-
TAG="$(date +%Y%m%dT%H%M)-git-${VCS_REF}"
9-
readonly TAG
5+
. ci/vars
106

117
# shellcheck disable=SC2154
128
docker login -u "${user}" -p "${pass}"

Diff for: ci/test

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -o pipefail
44

55
. ci/bootstrap
66
. ci/functions
7+
. ci/vars
78
. test/functions.bash
89

910
info 'Run file checks.'
@@ -21,9 +22,9 @@ for cid in $cids; do
2122
done
2223

2324
info "Create data container in which to download test files."
24-
run docker create --name downloads -v /home/user alpine:3.7 true
25+
run docker create --name downloads -v /home/user "${BASE_IMAGE}" true
2526
# Ensure the tftp client user has permissions on the volume.
26-
run docker run --rm --volumes-from downloads alpine:3.7 chown -R 1000:1000 /home/user
27+
run docker run --rm --volumes-from downloads "${BASE_IMAGE}" chown -R 1000:1000 /home/user
2728

2829
info "Create data container for fixtures."
2930
run docker create --name fixtures hooktftp-fixtures true

Diff for: src/alpine/builder/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM alpine:3.7 as builder
1+
ARG BASE_IMAGE
2+
FROM ${BASE_IMAGE} as builder
23

34
RUN apk add --no-cache \
45
busybox-extras \

Diff for: src/alpine/client/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM alpine:3.7
1+
ARG BASE_IMAGE
2+
FROM ${BASE_IMAGE}
23

34
# Install dependencies.
45
RUN apk add --no-cache tftp-hpa

Diff for: test/functional_tests.bats

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,37 @@ load functions
44
run docker logs tftpd
55
[[ ${output} =~ 'Dropped privileges' ]]
66

7-
docker run --rm -it --pid container:tftpd --network container:tftpd alpine:3.7 ps -o pid,user,group,comm |
7+
docker run --rm -it --pid container:tftpd --network container:tftpd "${BASE_IMAGE}" ps -o pid,user,group,comm |
88
grep -E '1 1000 1000 hooktftp'
99
}
1010

1111
@test "downloads site/menu from fixtures" {
1212
tftp_get $ip site/menu
13-
run docker run --rm --volumes-from downloads alpine:3.7 test -r /home/user/menu
13+
run docker run --rm --volumes-from downloads "${BASE_IMAGE}" test -r /home/user/menu
1414
[ ${status} -eq 0 ]
1515
}
1616

1717
@test "downloads pxelinux.0" {
1818
tftp_get $ip pxelinux.0
19-
run docker run --rm --volumes-from downloads alpine:3.7 test -s /home/user/pxelinux.0
19+
run docker run --rm --volumes-from downloads "${BASE_IMAGE}" test -s /home/user/pxelinux.0
2020
[ ${status} -eq 0 ]
2121
}
2222

2323
@test "does not download a non-existent-file" {
2424
tftp_get $ip non-existent-file
25-
run docker run --rm --volumes-from downloads alpine:3.7 test -s /home/user/non-existent-file
25+
run docker run --rm --volumes-from downloads "${BASE_IMAGE}" test -s /home/user/non-existent-file
2626
[ ${status} -ne 0 ]
2727
}
2828

2929
@test "downloads pxelinux.cfg/default" {
3030
tftp_get $ip pxelinux.cfg/default
31-
run docker run --rm --volumes-from downloads alpine:3.7 test -s /home/user/default
31+
run docker run --rm --volumes-from downloads "${BASE_IMAGE}" test -s /home/user/default
3232
[ ${status} -eq 0 ]
3333
}
3434

3535
@test "downloads pxelinux.cfg/F1.msg" {
3636
tftp_get $ip pxelinux.cfg/F1.msg
37-
run docker run --rm --volumes-from downloads alpine:3.7 test -s /home/user/F1.msg
37+
run docker run --rm --volumes-from downloads "${BASE_IMAGE}" test -s /home/user/F1.msg
3838
[ ${status} -eq 0 ]
3939
}
4040

Diff for: test/functions.bash

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# shellcheck shell=bash
2+
3+
. ci/vars
4+
25
docker_rm() {
36
cid=$1
47
docker rm -f "${cid}" &>/dev/null || :

0 commit comments

Comments
 (0)