Skip to content

Instantly share code, notes, and snippets.

@RemeJuan
Created Mar 30, 2016
Embed
What would you like to do?
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