Skip to content

Instantly share code, notes, and snippets.

@RemeJuan
Created March 30, 2016 12:50
Show Gist options
  • Save RemeJuan/e85e86add2520f7d4f3c97ca75300afe to your computer and use it in GitHub Desktop.
Save RemeJuan/e85e86add2520f7d4f3c97ca75300afe to your computer and use it in GitHub Desktop.
Complete docker sample file for automated deployment to digital ocean.
box: node
build:
steps:
- npm-install
deploy:
steps:
- script:
name: install nodemon
code: npm install -g nodemon
- internal/docker-push:
username: $DOCKER_USERNAME
password: $DOCKER_PASSWORD
cmd: /bin/bash -c "cd /pipeline/source && nodemon npm start"
repository: $DOCKER_REPO
registry: https://registry.hub.docker.com
- add-ssh-key:
keyname: DIGITAL_OCEAN
- add-to-known_hosts:
hostname: $SERVER_IP
- script:
name: pull latest image
code: ssh root@$SERVER_IP docker pull $DOCKER_REPO:latest
- script:
name: stop running container
code: ssh root@$SERVER_IP docker stop $APPLICATION_NAME || echo ‘failed to stop running container’
- script:
name: remove stopped container
code: ssh root@$SERVER_IP docker rm $APPLICATION_NAME || echo ‘failed to remove stopped container’
- script:
name: remove image behind stopped container
code: ssh root@$SERVER_IP> docker rmi $DOCKER_REPO:current || echo ‘failed to remove image behind stopped container’
- script:
name: tag newly pulled image
code: ssh root@$SERVER_IP docker tag $DOCKER_REPO:latest $DOCKER_REPO:current || echo ‘failed to change tag’
- script:
name: run new container
code: ssh root@$SERVER_IP docker run -d -p 80:$NODE_PORT --name $APPLICATION_NAME $DOCKER_REPO:current
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment