Skip to content

Instantly share code, notes, and snippets.

@krohne
Last active January 11, 2019 20:20
Show Gist options
  • Save krohne/c46042766cad635c2e26cfe8fb28962b to your computer and use it in GitHub Desktop.
Save krohne/c46042766cad635c2e26cfe8fb28962b to your computer and use it in GitHub Desktop.
Copy source file to remote platform docker container. If running from the repository path, container is optional
#!/bin/bash
# Your bastion username should be in ~/.ssh/config
# platform path [container]
# preprod /routes/genesys/router.js tripnotificationagent
export platform=$1
export repo=$(basename "$PWD")
export filename=$2
export container=$3
if [ -z ${container} ]; then export container=$(grep '"name":\s*"\w*",' $PWD/package.json | awk -F '"' '{ print $4 }'); fi
export service="rmpay_${container}_1"
export directory=$(dirname $filename)
ssh $platform mkdir -p staged/$repo/$directory
scp -r $PWD/$filename $platform:~/staged/$repo/$filename
ssh $platform /bin/bash << EOF
docker exec $service mkdir -p /usr/src/app/$directory
docker cp ~/staged/$repo/$filename $service:/usr/src/app/$filename
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment