Skip to content

Commit 857c730

Browse files
committed
New function to copy the current working docker container to my test server
1 parent 7601fdc commit 857c730

File tree

1 file changed

+14
-3
lines changed
  • samba-timemachine

1 file changed

+14
-3
lines changed

samba-timemachine/run

+14-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
set -eu -o pipefail
33
IMAGE_NAME=samba-timemachine
44
PLATFORMS="linux/amd64,linux/arm64,linux/arm/v7"
5+
TESTHOST=carbon
56

67
build () {
78
docker build "${@}" -t "${IMAGE_NAME}:tmp" -f Dockerfile .
89
}
910

1011
clean () {
11-
docker image rm "${IMAGE_NAME}:tmp"
12+
docker image rm "${IMAGE_NAME}:tmp" || true
1213
}
1314

1415
_test() {
@@ -37,10 +38,10 @@ release() {
3738
docker buildx inspect --bootstrap
3839
docker buildx build \
3940
--platform "${PLATFORMS}" \
40-
-t "timjdfletcher/${IMAGE_NAME}:${TAG}" --load .
41+
-t "timjdfletcher/${IMAGE_NAME}:${TAG}" --push .
4142
docker buildx build \
4243
--platform "${PLATFORMS}" \
43-
-t "timjdfletcher/${IMAGE_NAME}:latest" --load .
44+
-t "timjdfletcher/${IMAGE_NAME}:latest" --push .
4445
}
4546

4647
push() {
@@ -52,6 +53,15 @@ push() {
5253
docker push "timjdfletcher/${IMAGE_NAME}:latest"
5354
}
5455

56+
copyToTestHost () {
57+
build --quiet
58+
size=$(docker image inspect samba-timemachine:tmp | jq -r '.[0].Size')
59+
docker save "${IMAGE_NAME}:tmp" |\
60+
pigz -c |\
61+
pv -s "${size}" |\
62+
ssh -C "${TESTHOST}" "pigz -d | docker load"
63+
}
64+
5565
CMD=${1:-}
5666

5767
shift || true
@@ -60,6 +70,7 @@ case ${CMD} in
6070
clean) clean ;;
6171
test) _test ;;
6272
push) push ;;
73+
copyToTestHost) copyToTestHost ;;
6374
release) release ;;
6475
*) usage ;;
6576
esac

0 commit comments

Comments
 (0)