Skip to content

Commit 3934150

Browse files
committed
Have libexec scripts be able to communicate with a docker container
start-target creates and starts a docker container from the image created by make-base-vm stop-target stops and removes the docker container from start-target copy-from-target, copy-to-target, and on-target can execute commands and copy files to and from the docker container started by start-target. make-clean-vm does nothing because nothing needs to be done to make a clean docker container.
1 parent 1ca59fd commit 3934150

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

libexec/copy-from-target

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ if [ $# = 0 ] ; then
4646
exit 1
4747
fi
4848

49-
if [ -z "$USE_LXC" ]; then
49+
if [ -n "$USE_DOCKER" ]; then
50+
docker cp gitian-target:"/home/$TUSER/$1" $2
51+
elif [ -z "$USE_LXC" ]; then
5052
src="${1%/}" # remove trailing / which triggers special rsync behaviour
5153
rsync --checksum -a $QUIET_FLAG -e "ssh -oConnectTimeout=30 -oNoHostAuthenticationForLocalhost=yes -i ${GITIAN_BASE:-.}/var/id_rsa -p $VM_SSH_PORT" "$TUSER@localhost:${src}" "$2"
5254
else

libexec/copy-to-target

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ if [ $# = 0 ] ; then
4646
exit 1
4747
fi
4848

49-
if [ -z "$USE_LXC" ]; then
49+
if [ -n "$USE_DOCKER" ]; then
50+
docker exec -u $TUSER gitian-target mkdir -p "/home/$TUSER/$2"
51+
docker cp "$1" gitian-target:"/home/$TUSER/$2"
52+
elif [ -z "$USE_LXC" ]; then
5053
src="${1%/}" # remove trailing / which triggers special rsync behaviour
5154
rsync --checksum -a $QUIET_FLAG -e "ssh -oConnectTimeout=30 -oNoHostAuthenticationForLocalhost=yes -i ${GITIAN_BASE:-.}/var/id_rsa -p $VM_SSH_PORT" "${src}" "$TUSER@localhost:$2"
5255
else

libexec/make-clean-vm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ if [ -n "$USE_LXC" ]; then
99
VMSW=LXC
1010
elif [ -n "$USE_VBOX" ]; then
1111
VMSW=VBOX
12+
elif [ -n "$USE_DOCKER" ]; then
13+
VMSW=DOCKER
1214
fi
1315

1416
usage() {
@@ -66,4 +68,7 @@ case $VMSW in
6668
VBOX)
6769
VBoxManage snapshot "Gitian-${SUITE}-${ARCH}" restore "Gitian-Clean"
6870
;;
71+
DOCKER)
72+
true #Docker doesn't need to do anything
73+
;;
6974
esac

libexec/on-target

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ fi
4646
# exit 1
4747
#fi
4848

49-
if [ -z "$USE_LXC" ]; then
49+
if [ -n "$USE_DOCKER" ]; then
50+
docker exec -u $TUSER -i gitian-target $*
51+
elif [ -z "$USE_LXC" ]; then
5052
ssh -oConnectTimeout=30 -oNoHostAuthenticationForLocalhost=yes -i ${GITIAN_BASE:-.}/var/id_rsa -p $VM_SSH_PORT $TUSER@localhost $*
5153
else
5254
config-lxc

libexec/start-target

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ if [ -n "$USE_LXC" ]; then
1010
VMSW=LXC
1111
elif [ -n "$USE_VBOX" ]; then
1212
VMSW=VBOX
13+
elif [ -n "$USE_DOCKER" ]; then
14+
VMSW=DOCKER
1315
fi
1416

1517
case $VMSW in
@@ -34,4 +36,7 @@ case $VMSW in
3436
VBoxManage startvm "Gitian-${2}" --type headless
3537
echo "Gitian-${2}" > var/target.vmname
3638
;;
39+
DOCKER)
40+
docker run -d --name gitian-target base-$SUFFIX:latest > /dev/null
41+
;;
3742
esac

libexec/stop-target

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ if [ -n "$USE_LXC" ]; then
55
VMSW=LXC
66
elif [ -n "$USE_VBOX" ]; then
77
VMSW=VBOX
8+
elif [ -n "$USE_DOCKER" ]; then
9+
VMSW=DOCKER
810
fi
911

1012
case $VMSW in
@@ -30,4 +32,8 @@ case $VMSW in
3032
VBoxManage controlvm `cat var/target.vmname` savestate
3133
rm var/target.vmname
3234
;;
35+
DOCKER)
36+
docker container stop gitian-target > /dev/null
37+
docker container rm gitian-target > /dev/null
38+
;;
3339
esac

0 commit comments

Comments
 (0)