Skip to content

Instantly share code, notes, and snippets.

@stampycode
Last active May 17, 2017 08:32
Show Gist options
  • Save stampycode/fc031396ebd5b55df74b43585b4a9b1a to your computer and use it in GitHub Desktop.
Save stampycode/fc031396ebd5b55df74b43585b4a9b1a to your computer and use it in GitHub Desktop.
how to BASH SSH and SUDO
ssh ${SERVER} <<ENDSSH
cd ${REPO}
sudo -s -- <<SUDO
unset HISTFILE
[[ ! -d /root/.docker ]] && mkdir /root/.docker
[[ ! -e /root/.docker/config.json ]] && echo '{"credsStore": "registrycreds"}' > /root/.docker/config.json
[[ ! -d /root/bin ]] && mkdir /root/bin
echo > /root/bin/docker-credential-registrycreds <<<RRR
#!/bin/bash
cat <<JSON
{
"ServerURL": "${REGISTRYSERVER}",
"Username": "${DOCKER_USER}",
"Secret": "${DOCKER_PASS}"
}
JSON
RRR
chmod u+x /root/bin/docker-credential-registrycreds
export PATH=$PATH:/root/bin
export DOCKER_USER="${DOCKERUSER}"
export DOCKER_PASS="${DOCKERPASS}"
docker pull ${REGISTRYSERVER}/${REPO}:${VER}
docker-compose up --build -d ${REPO}
SUDO
ENDSSH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment