Skip to content

Instantly share code, notes, and snippets.

@mbenedettini
Created June 25, 2017 21:47
Show Gist options
  • Save mbenedettini/1bc4543fc0701e1f4c3678f192be7d65 to your computer and use it in GitHub Desktop.
Save mbenedettini/1bc4543fc0701e1f4c3678f192be7d65 to your computer and use it in GitHub Desktop.
branches:
- [master, develop]
pipeline:
build:
image: docker:latest
environment:
- REGISTRY_USERNAME=${REGISTRY_USERNAME}
- REGISTRY_PASSWORD=${REGISTRY_PASSWORD}
- NODE_ENV=production
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- docker build -t myregistry.codexia.io/myproject -f Dockerfile-prod .
- docker login -u "$REGISTRY_USERNAME" -p "$REGISTRY_PASSWORD" https://myregistry.codexia.io
- docker push myregistry.codexia.io/myproject
scp:
# update docker-compose files
when:
branch: develop
image: appleboy/drone-scp
host: anotherhostname
username: irtextranet
key: ${DEPLOY_KEY}
source:
- docker-compose.yml
- docker-compose.prod.yml
target:
- /home/irtextranet
ssh:
# Pull images and issue the required commands to deploy
when:
branch: develop
image: appleboy/drone-ssh
host: 10.2.169.197
username: myproject
key: ${DEPLOY_KEY}
port: 22
script:
- /usr/local/bin/docker-compose -f docker-compose.yml -f docker-compose.prod.yml pull && /usr/local/bin/docker-compose -f docker-compose.yml -f docker-compose.prod.yml down && /usr/local/bin/docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d --force-recreate && /usr/local/bin/docker-compose -f docker-compose.yml -f docker-compose.prod.yml exec -T server npm run migrate up
ssh:
# Production environment is Swarm-based
when:
branch: master
image: appleboy/drone-ssh
host: myprojecthost.codexia.io
username: drone-deploy
key: ${DEPLOY_KEY_PROD}
port: 22
script:
- sudo docker service update myproject-worker --image registry.codexia.io/myproject:latest
- sudo docker service update myproject-server --image registry.codexia.io/myproject:latest
notify:
image: drillster/drone-email
host: smtp.mailgun.org
username: ${SMTP_USERNAME}
password: ${SMTP_PASSWORD}
from: [email protected]
recipients: [ [email protected] ]
when:
status: [ success, changed, failure ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment