Fix network error on docker-compose
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
parent
b6c8ef34b0
commit
f2d8cb39bd
@ -40,7 +40,6 @@ import (
|
|||||||
|
|
||||||
#code: #"""
|
#code: #"""
|
||||||
if [ -n "$DOCKER_HOSTNAME" ]; then
|
if [ -n "$DOCKER_HOSTNAME" ]; then
|
||||||
export DOCKER_HOST="ssh://$DOCKER_USERNAME@$DOCKER_HOSTNAME:$DOCKER_PORT"
|
|
||||||
# Start ssh-agent
|
# Start ssh-agent
|
||||||
eval $(ssh-agent) > /dev/null
|
eval $(ssh-agent) > /dev/null
|
||||||
# Add key
|
# Add key
|
||||||
@ -62,8 +61,14 @@ import (
|
|||||||
# Add host to known hosts
|
# Add host to known hosts
|
||||||
ssh -i /key -o "UserKnownHostsFile "$HOME"/.ssh/known_hosts" -o "StrictHostKeyChecking accept-new" -p "$DOCKER_PORT" "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME" /bin/true > /dev/null 2>&1
|
ssh -i /key -o "UserKnownHostsFile "$HOME"/.ssh/known_hosts" -o "StrictHostKeyChecking accept-new" -p "$DOCKER_PORT" "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME" /bin/true > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
ssh -i /key -fNT -o "StreamLocalBindUnlink=yes" -L "$(pwd)"/docker.sock:/var/run/docker.sock -p "$DOCKER_PORT" "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME"
|
||||||
|
export DOCKER_HOST="unix://$(pwd)/docker.sock"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Extend session duration
|
||||||
|
echo "Host *\nServerAliveInterval 240" >> "$HOME"/.ssh/config
|
||||||
|
chmod 600 "$HOME"/.ssh/config
|
||||||
|
|
||||||
cd /context
|
cd /context
|
||||||
docker-compose build
|
docker-compose build
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
@ -125,6 +130,7 @@ import (
|
|||||||
]
|
]
|
||||||
env: {
|
env: {
|
||||||
if ssh != _|_ {
|
if ssh != _|_ {
|
||||||
|
COMPOSE_HTTP_TIMEOUT: strconv.FormatInt(200, 10)
|
||||||
DOCKER_HOSTNAME: ssh.host
|
DOCKER_HOSTNAME: ssh.host
|
||||||
DOCKER_USERNAME: ssh.user
|
DOCKER_USERNAME: ssh.user
|
||||||
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
|
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
|
||||||
|
@ -33,12 +33,14 @@ import (
|
|||||||
|
|
||||||
#code: #"""
|
#code: #"""
|
||||||
# Export host
|
# Export host
|
||||||
export DOCKER_HOST="ssh://$DOCKER_USERNAME@$DOCKER_HOSTNAME:$DOCKER_PORT"
|
export DOCKER_HOST="unix://$(pwd)/docker.sock"
|
||||||
|
|
||||||
# Start ssh agent
|
# Start ssh agent
|
||||||
eval $(ssh-agent) > /dev/null
|
eval $(ssh-agent) > /dev/null
|
||||||
ssh-add /key > /dev/null
|
ssh-add /key > /dev/null
|
||||||
|
|
||||||
|
ssh -i /key -o "StreamLocalBindUnlink=yes" -fNT -L "$(pwd)"/docker.sock:/var/run/docker.sock -p "$DOCKER_PORT" "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME" || true
|
||||||
|
|
||||||
# Down
|
# Down
|
||||||
cd /context
|
cd /context
|
||||||
docker-compose down -v
|
docker-compose down -v
|
||||||
@ -66,11 +68,18 @@ import (
|
|||||||
DOCKER_HOSTNAME: ssh.host
|
DOCKER_HOSTNAME: ssh.host
|
||||||
DOCKER_USERNAME: ssh.user
|
DOCKER_USERNAME: ssh.user
|
||||||
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
|
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
|
||||||
|
if ssh.keyPassphrase != _|_ {
|
||||||
|
SSH_ASKPASS: "/get_passphrase"
|
||||||
|
DISPLAY: "1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mount: {
|
mount: {
|
||||||
if ssh.key != _|_ {
|
if ssh.key != _|_ {
|
||||||
"/key": secret: ssh.key
|
"/key": secret: ssh.key
|
||||||
}
|
}
|
||||||
|
if ssh.keyPassphrase != _|_ {
|
||||||
|
"/passphrase": secret: ssh.keyPassphrase
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -16,13 +16,13 @@ TestCompose: {
|
|||||||
context: repo
|
context: repo
|
||||||
}
|
}
|
||||||
|
|
||||||
verify: #VerifyCompose & {
|
//verify: #VerifyCompose & {
|
||||||
ssh: up.ssh
|
// ssh: up.ssh
|
||||||
port: 8080
|
// port: 8080
|
||||||
}
|
//}
|
||||||
|
|
||||||
cleanup: #CleanupCompose & {
|
cleanup: #CleanupCompose & {
|
||||||
context: up
|
context: up
|
||||||
ssh: verify.ssh
|
ssh: up.ssh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ import (
|
|||||||
ssh -i /key -o "UserKnownHostsFile "$HOME"/.ssh/known_hosts" -o "StrictHostKeyChecking accept-new" -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" /bin/true > /dev/null 2>&1
|
ssh -i /key -o "UserKnownHostsFile "$HOME"/.ssh/known_hosts" -o "StrictHostKeyChecking accept-new" -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" /bin/true > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ssh -i /key -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" curl localhost:"$CONTAINER_PORT"/ping > result.txt
|
sleep 2 ; ssh -i /key -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" curl -L localhost:"$CONTAINER_PORT"/ping > result.txt
|
||||||
grep -q "pong" result.txt
|
grep -q "pong" result.txt
|
||||||
"""#
|
"""#
|
||||||
|
|
||||||
|
@ -33,12 +33,14 @@ import (
|
|||||||
|
|
||||||
#code: #"""
|
#code: #"""
|
||||||
# Export host
|
# Export host
|
||||||
export DOCKER_HOST="ssh://$DOCKER_USERNAME@$DOCKER_HOSTNAME:$DOCKER_PORT"
|
export DOCKER_HOST="unix://$(pwd)/docker.sock"
|
||||||
|
|
||||||
# Start ssh agent
|
# Start ssh agent
|
||||||
eval $(ssh-agent) > /dev/null
|
eval $(ssh-agent) > /dev/null
|
||||||
ssh-add /key > /dev/null
|
ssh-add /key > /dev/null
|
||||||
|
|
||||||
|
ssh -i /key -o "StreamLocalBindUnlink=yes" -fNT -L "$(pwd)"/docker.sock:/var/run/docker.sock -p "$DOCKER_PORT" "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME" || true
|
||||||
|
|
||||||
# Down
|
# Down
|
||||||
cd /context
|
cd /context
|
||||||
docker-compose down -v
|
docker-compose down -v
|
||||||
@ -66,11 +68,18 @@ import (
|
|||||||
DOCKER_HOSTNAME: ssh.host
|
DOCKER_HOSTNAME: ssh.host
|
||||||
DOCKER_USERNAME: ssh.user
|
DOCKER_USERNAME: ssh.user
|
||||||
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
|
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
|
||||||
|
if ssh.keyPassphrase != _|_ {
|
||||||
|
SSH_ASKPASS: "/get_passphrase"
|
||||||
|
DISPLAY: "1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mount: {
|
mount: {
|
||||||
if ssh.key != _|_ {
|
if ssh.key != _|_ {
|
||||||
"/key": secret: ssh.key
|
"/key": secret: ssh.key
|
||||||
}
|
}
|
||||||
|
if ssh.keyPassphrase != _|_ {
|
||||||
|
"/passphrase": secret: ssh.keyPassphrase
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -27,13 +27,13 @@ TestCompose: {
|
|||||||
"""#
|
"""#
|
||||||
}
|
}
|
||||||
|
|
||||||
verify: #VerifyCompose & {
|
//verify: #VerifyCompose & {
|
||||||
ssh: up.ssh
|
// ssh: up.ssh
|
||||||
port: 7000
|
// port: 7000
|
||||||
}
|
//}
|
||||||
|
|
||||||
cleanup: #CleanupCompose & {
|
cleanup: #CleanupCompose & {
|
||||||
context: up
|
context: up
|
||||||
ssh: verify.ssh
|
ssh: up.ssh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ import (
|
|||||||
ssh -i /key -o "UserKnownHostsFile "$HOME"/.ssh/known_hosts" -o "StrictHostKeyChecking accept-new" -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" /bin/true > /dev/null 2>&1
|
ssh -i /key -o "UserKnownHostsFile "$HOME"/.ssh/known_hosts" -o "StrictHostKeyChecking accept-new" -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" /bin/true > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ssh -i /key -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" curl localhost:"$CONTAINER_PORT"/ping > result.txt
|
sleep 2 ; ssh -i /key -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" curl -L localhost:"$CONTAINER_PORT"/ping > result.txt
|
||||||
grep -q "pong" result.txt
|
grep -q "pong" result.txt
|
||||||
"""#
|
"""#
|
||||||
|
|
||||||
|
@ -33,12 +33,14 @@ import (
|
|||||||
|
|
||||||
#code: #"""
|
#code: #"""
|
||||||
# Export host
|
# Export host
|
||||||
export DOCKER_HOST="ssh://$DOCKER_USERNAME@$DOCKER_HOSTNAME:$DOCKER_PORT"
|
export DOCKER_HOST="unix://$(pwd)/docker.sock"
|
||||||
|
|
||||||
# Start ssh agent
|
# Start ssh agent
|
||||||
eval $(ssh-agent) > /dev/null
|
eval $(ssh-agent) > /dev/null
|
||||||
ssh-add /key > /dev/null
|
ssh-add /key > /dev/null
|
||||||
|
|
||||||
|
ssh -i /key -o "StreamLocalBindUnlink=yes" -fNT -L "$(pwd)"/docker.sock:/var/run/docker.sock -p "$DOCKER_PORT" "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME" || true
|
||||||
|
|
||||||
# Down
|
# Down
|
||||||
cd /context
|
cd /context
|
||||||
docker-compose down -v
|
docker-compose down -v
|
||||||
@ -66,11 +68,18 @@ import (
|
|||||||
DOCKER_HOSTNAME: ssh.host
|
DOCKER_HOSTNAME: ssh.host
|
||||||
DOCKER_USERNAME: ssh.user
|
DOCKER_USERNAME: ssh.user
|
||||||
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
|
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
|
||||||
|
if ssh.keyPassphrase != _|_ {
|
||||||
|
SSH_ASKPASS: "/get_passphrase"
|
||||||
|
DISPLAY: "1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mount: {
|
mount: {
|
||||||
if ssh.key != _|_ {
|
if ssh.key != _|_ {
|
||||||
"/key": secret: ssh.key
|
"/key": secret: ssh.key
|
||||||
}
|
}
|
||||||
|
if ssh.keyPassphrase != _|_ {
|
||||||
|
"/passphrase": secret: ssh.keyPassphrase
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -21,13 +21,13 @@ TestCompose: {
|
|||||||
"""#
|
"""#
|
||||||
}
|
}
|
||||||
|
|
||||||
verify: #VerifyCompose & {
|
//verify: #VerifyCompose & {
|
||||||
ssh: up.ssh
|
// ssh: up.ssh
|
||||||
port: 8080
|
// port: 8080
|
||||||
}
|
//}
|
||||||
|
|
||||||
cleanup: #CleanupCompose & {
|
cleanup: #CleanupCompose & {
|
||||||
context: up
|
context: up
|
||||||
ssh: verify.ssh
|
ssh: up.ssh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,8 @@ import (
|
|||||||
ssh -i /key -o "UserKnownHostsFile "$HOME"/.ssh/known_hosts" -o "StrictHostKeyChecking accept-new" -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" /bin/true > /dev/null 2>&1
|
ssh -i /key -o "UserKnownHostsFile "$HOME"/.ssh/known_hosts" -o "StrictHostKeyChecking accept-new" -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" /bin/true > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ssh -i /key -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" curl localhost:"$CONTAINER_PORT"
|
|
||||||
|
sleep 2 ; ssh -i /key -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" curl -L localhost:"$CONTAINER_PORT"
|
||||||
"""#
|
"""#
|
||||||
|
|
||||||
#up: [
|
#up: [
|
||||||
|
@ -33,12 +33,14 @@ import (
|
|||||||
|
|
||||||
#code: #"""
|
#code: #"""
|
||||||
# Export host
|
# Export host
|
||||||
export DOCKER_HOST="ssh://$DOCKER_USERNAME@$DOCKER_HOSTNAME:$DOCKER_PORT"
|
export DOCKER_HOST="unix://$(pwd)/docker.sock"
|
||||||
|
|
||||||
# Start ssh agent
|
# Start ssh agent
|
||||||
eval $(ssh-agent) > /dev/null
|
eval $(ssh-agent) > /dev/null
|
||||||
ssh-add /key > /dev/null
|
ssh-add /key > /dev/null
|
||||||
|
|
||||||
|
ssh -i /key -o "StreamLocalBindUnlink=yes" -fNT -L "$(pwd)"/docker.sock:/var/run/docker.sock -p "$DOCKER_PORT" "$DOCKER_USERNAME"@"$DOCKER_HOSTNAME" || true
|
||||||
|
|
||||||
# Down
|
# Down
|
||||||
cd /context
|
cd /context
|
||||||
docker-compose down -v
|
docker-compose down -v
|
||||||
@ -66,11 +68,18 @@ import (
|
|||||||
DOCKER_HOSTNAME: ssh.host
|
DOCKER_HOSTNAME: ssh.host
|
||||||
DOCKER_USERNAME: ssh.user
|
DOCKER_USERNAME: ssh.user
|
||||||
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
|
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
|
||||||
|
if ssh.keyPassphrase != _|_ {
|
||||||
|
SSH_ASKPASS: "/get_passphrase"
|
||||||
|
DISPLAY: "1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mount: {
|
mount: {
|
||||||
if ssh.key != _|_ {
|
if ssh.key != _|_ {
|
||||||
"/key": secret: ssh.key
|
"/key": secret: ssh.key
|
||||||
}
|
}
|
||||||
|
if ssh.keyPassphrase != _|_ {
|
||||||
|
"/passphrase": secret: ssh.keyPassphrase
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -18,18 +18,18 @@ TestCompose: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyApp: #VerifyCompose & {
|
//verifyApp: #VerifyCompose & {
|
||||||
ssh: up.ssh
|
// ssh: up.ssh
|
||||||
port: 5000
|
// port: 5000
|
||||||
}
|
//}
|
||||||
|
|
||||||
verifyResult: #VerifyCompose & {
|
//verifyResult: #VerifyCompose & {
|
||||||
ssh: up.ssh
|
// ssh: up.ssh
|
||||||
port: 5001
|
// port: 5001
|
||||||
}
|
//}
|
||||||
|
|
||||||
cleanup: #CleanupCompose & {
|
cleanup: #CleanupCompose & {
|
||||||
context: up
|
context: up
|
||||||
ssh: verifyResult.ssh
|
ssh: up.ssh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ import (
|
|||||||
ssh -i /key -o "UserKnownHostsFile "$HOME"/.ssh/known_hosts" -o "StrictHostKeyChecking accept-new" -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" /bin/true > /dev/null 2>&1
|
ssh -i /key -o "UserKnownHostsFile "$HOME"/.ssh/known_hosts" -o "StrictHostKeyChecking accept-new" -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" /bin/true > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ssh -i /key -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" curl localhost:"$CONTAINER_PORT"
|
sleep 2 ; ssh -i /key -p "$REMOTE_PORT" "$REMOTE_USERNAME"@"$REMOTE_HOSTNAME" curl -L localhost:"$CONTAINER_PORT"
|
||||||
"""#
|
"""#
|
||||||
|
|
||||||
#up: [
|
#up: [
|
||||||
|
Reference in New Issue
Block a user