Browse Source

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.
pull/181/head
Andrew Chow 2 years ago
parent
commit
3934150c5a
6 changed files with 26 additions and 3 deletions
  1. 3
    1
      libexec/copy-from-target
  2. 4
    1
      libexec/copy-to-target
  3. 5
    0
      libexec/make-clean-vm
  4. 3
    1
      libexec/on-target
  5. 5
    0
      libexec/start-target
  6. 6
    0
      libexec/stop-target

+ 3
- 1
libexec/copy-from-target View File

@@ -46,7 +46,9 @@ if [ $# = 0 ] ; then
exit 1
fi

if [ -z "$USE_LXC" ]; then
if [ -n "$USE_DOCKER" ]; then
docker cp gitian-target:"/home/$TUSER/$1" $2
elif [ -z "$USE_LXC" ]; then
src="${1%/}" # remove trailing / which triggers special rsync behaviour
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"
else

+ 4
- 1
libexec/copy-to-target View File

@@ -46,7 +46,10 @@ if [ $# = 0 ] ; then
exit 1
fi

if [ -z "$USE_LXC" ]; then
if [ -n "$USE_DOCKER" ]; then
docker exec -u $TUSER gitian-target mkdir -p "/home/$TUSER/$2"
docker cp "$1" gitian-target:"/home/$TUSER/$2"
elif [ -z "$USE_LXC" ]; then
src="${1%/}" # remove trailing / which triggers special rsync behaviour
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"
else

+ 5
- 0
libexec/make-clean-vm View File

@@ -9,6 +9,8 @@ if [ -n "$USE_LXC" ]; then
VMSW=LXC
elif [ -n "$USE_VBOX" ]; then
VMSW=VBOX
elif [ -n "$USE_DOCKER" ]; then
VMSW=DOCKER
fi

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

+ 3
- 1
libexec/on-target View File

@@ -46,7 +46,9 @@ fi
# exit 1
#fi

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

+ 5
- 0
libexec/start-target View File

@@ -10,6 +10,8 @@ if [ -n "$USE_LXC" ]; then
VMSW=LXC
elif [ -n "$USE_VBOX" ]; then
VMSW=VBOX
elif [ -n "$USE_DOCKER" ]; then
VMSW=DOCKER
fi

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

+ 6
- 0
libexec/stop-target View File

@@ -5,6 +5,8 @@ if [ -n "$USE_LXC" ]; then
VMSW=LXC
elif [ -n "$USE_VBOX" ]; then
VMSW=VBOX
elif [ -n "$USE_DOCKER" ]; then
VMSW=DOCKER
fi

case $VMSW in
@@ -30,4 +32,8 @@ case $VMSW in
VBoxManage controlvm `cat var/target.vmname` savestate
rm var/target.vmname
;;
DOCKER)
docker container stop gitian-target > /dev/null
docker container rm gitian-target > /dev/null
;;
esac

Loading…
Cancel
Save