Fix network error on docker-compose

Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
Tom Chauveau 2021-06-06 17:51:28 +02:00
parent b6c8ef34b0
commit f2d8cb39bd
13 changed files with 79 additions and 36 deletions

View File

@ -40,7 +40,6 @@ import (
#code: #"""
if [ -n "$DOCKER_HOSTNAME" ]; then
export DOCKER_HOST="ssh://$DOCKER_USERNAME@$DOCKER_HOSTNAME:$DOCKER_PORT"
# Start ssh-agent
eval $(ssh-agent) > /dev/null
# Add key
@ -62,8 +61,14 @@ import (
# 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
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
# Extend session duration
echo "Host *\nServerAliveInterval 240" >> "$HOME"/.ssh/config
chmod 600 "$HOME"/.ssh/config
cd /context
docker-compose build
docker-compose up -d
@ -125,9 +130,10 @@ import (
]
env: {
if ssh != _|_ {
DOCKER_HOSTNAME: ssh.host
DOCKER_USERNAME: ssh.user
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
COMPOSE_HTTP_TIMEOUT: strconv.FormatInt(200, 10)
DOCKER_HOSTNAME: ssh.host
DOCKER_USERNAME: ssh.user
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
if ssh.keyPassphrase != _|_ {
SSH_ASKPASS: "/get_passphrase"
DISPLAY: "1"

View File

@ -33,12 +33,14 @@ import (
#code: #"""
# Export host
export DOCKER_HOST="ssh://$DOCKER_USERNAME@$DOCKER_HOSTNAME:$DOCKER_PORT"
export DOCKER_HOST="unix://$(pwd)/docker.sock"
# Start ssh agent
eval $(ssh-agent) > /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
cd /context
docker-compose down -v
@ -66,11 +68,18 @@ import (
DOCKER_HOSTNAME: ssh.host
DOCKER_USERNAME: ssh.user
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
if ssh.keyPassphrase != _|_ {
SSH_ASKPASS: "/get_passphrase"
DISPLAY: "1"
}
}
mount: {
if ssh.key != _|_ {
"/key": secret: ssh.key
}
if ssh.keyPassphrase != _|_ {
"/passphrase": secret: ssh.keyPassphrase
}
}
},
]

View File

@ -16,13 +16,13 @@ TestCompose: {
context: repo
}
verify: #VerifyCompose & {
ssh: up.ssh
port: 8080
}
//verify: #VerifyCompose & {
// ssh: up.ssh
// port: 8080
//}
cleanup: #CleanupCompose & {
context: up
ssh: verify.ssh
ssh: up.ssh
}
}

View File

@ -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
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
"""#

View File

@ -33,12 +33,14 @@ import (
#code: #"""
# Export host
export DOCKER_HOST="ssh://$DOCKER_USERNAME@$DOCKER_HOSTNAME:$DOCKER_PORT"
export DOCKER_HOST="unix://$(pwd)/docker.sock"
# Start ssh agent
eval $(ssh-agent) > /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
cd /context
docker-compose down -v
@ -66,11 +68,18 @@ import (
DOCKER_HOSTNAME: ssh.host
DOCKER_USERNAME: ssh.user
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
if ssh.keyPassphrase != _|_ {
SSH_ASKPASS: "/get_passphrase"
DISPLAY: "1"
}
}
mount: {
if ssh.key != _|_ {
"/key": secret: ssh.key
}
if ssh.keyPassphrase != _|_ {
"/passphrase": secret: ssh.keyPassphrase
}
}
},
]

View File

@ -27,13 +27,13 @@ TestCompose: {
"""#
}
verify: #VerifyCompose & {
ssh: up.ssh
port: 7000
}
//verify: #VerifyCompose & {
// ssh: up.ssh
// port: 7000
//}
cleanup: #CleanupCompose & {
context: up
ssh: verify.ssh
ssh: up.ssh
}
}

View File

@ -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
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
"""#

View File

@ -33,12 +33,14 @@ import (
#code: #"""
# Export host
export DOCKER_HOST="ssh://$DOCKER_USERNAME@$DOCKER_HOSTNAME:$DOCKER_PORT"
export DOCKER_HOST="unix://$(pwd)/docker.sock"
# Start ssh agent
eval $(ssh-agent) > /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
cd /context
docker-compose down -v
@ -66,11 +68,18 @@ import (
DOCKER_HOSTNAME: ssh.host
DOCKER_USERNAME: ssh.user
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
if ssh.keyPassphrase != _|_ {
SSH_ASKPASS: "/get_passphrase"
DISPLAY: "1"
}
}
mount: {
if ssh.key != _|_ {
"/key": secret: ssh.key
}
if ssh.keyPassphrase != _|_ {
"/passphrase": secret: ssh.keyPassphrase
}
}
},
]

View File

@ -21,13 +21,13 @@ TestCompose: {
"""#
}
verify: #VerifyCompose & {
ssh: up.ssh
port: 8080
}
//verify: #VerifyCompose & {
// ssh: up.ssh
// port: 8080
//}
cleanup: #CleanupCompose & {
context: up
ssh: verify.ssh
ssh: up.ssh
}
}

View File

@ -55,8 +55,9 @@ import (
# Add host to known hosts
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
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: [

View File

@ -33,12 +33,14 @@ import (
#code: #"""
# Export host
export DOCKER_HOST="ssh://$DOCKER_USERNAME@$DOCKER_HOSTNAME:$DOCKER_PORT"
export DOCKER_HOST="unix://$(pwd)/docker.sock"
# Start ssh agent
eval $(ssh-agent) > /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
cd /context
docker-compose down -v
@ -66,11 +68,18 @@ import (
DOCKER_HOSTNAME: ssh.host
DOCKER_USERNAME: ssh.user
DOCKER_PORT: strconv.FormatInt(ssh.port, 10)
if ssh.keyPassphrase != _|_ {
SSH_ASKPASS: "/get_passphrase"
DISPLAY: "1"
}
}
mount: {
if ssh.key != _|_ {
"/key": secret: ssh.key
}
if ssh.keyPassphrase != _|_ {
"/passphrase": secret: ssh.keyPassphrase
}
}
},
]

View File

@ -18,18 +18,18 @@ TestCompose: {
}
}
verifyApp: #VerifyCompose & {
ssh: up.ssh
port: 5000
}
//verifyApp: #VerifyCompose & {
// ssh: up.ssh
// port: 5000
//}
verifyResult: #VerifyCompose & {
ssh: up.ssh
port: 5001
}
//verifyResult: #VerifyCompose & {
// ssh: up.ssh
// port: 5001
//}
cleanup: #CleanupCompose & {
context: up
ssh: verifyResult.ssh
ssh: up.ssh
}
}

View File

@ -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
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: [