mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-05 00:08:06 +08:00
test/ipfs-test-lib: add docker support
We have to do something special for CircleCI in docker_exec() because "docker exec" doesn't work on CircleCi: https://circleci.com/docs/docker#docker-exec We indeed get "Unsupported: Exec is not supported by the lxc driver" with CircleCi, when using "docker exec". License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
This commit is contained in:
parent
1c403c0380
commit
29ec4c06e4
@ -3,6 +3,7 @@ machine:
|
||||
TEST_NO_FUSE: 1
|
||||
TEST_VERBOSE: 1
|
||||
TRAVIS: 1
|
||||
CIRCLE: 1
|
||||
post:
|
||||
- sudo rm -rf /usr/local/go
|
||||
- if [ ! -e go1.5.linux-amd64.tar.gz ]; then curl -o go1.5.linux-amd64.tar.gz https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz; fi
|
||||
|
||||
@ -35,3 +35,30 @@ shellquote() {
|
||||
done
|
||||
printf '\n'
|
||||
}
|
||||
|
||||
# Docker
|
||||
|
||||
# This takes a directory, that should contain a Dockerfile, as argument
|
||||
docker_build() {
|
||||
docker build --rm "$1"
|
||||
}
|
||||
|
||||
# This takes an image as argument and writes a docker ID on stdout
|
||||
docker_run() {
|
||||
docker run -it -d -p 8080:8080 -p 4001:4001 -p 5001:5001 "$1"
|
||||
}
|
||||
|
||||
# This takes a docker ID and a command as arguments
|
||||
docker_exec() {
|
||||
if test "$CIRCLE" = 1
|
||||
then
|
||||
sudo lxc-attach -n "$(docker inspect --format '{{.Id}}' $1)" -- /bin/bash -c "$2"
|
||||
else
|
||||
docker exec -i "$1" /bin/bash -c "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
# This takes a docker ID as argument
|
||||
docker_stop() {
|
||||
docker stop "$1"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user