Feb 09, 2019 · ⏱ 1 minute

Simplifying Docker deployments with compose-deploy 🎯

When developing dockerized applications, you might stumble upon the sheer difficulty and annoyance of simply deploying your Compose file along with built service images. If you're not using a full cloud setup and instead want to deploy to a small number of machines, you're left with doing it manually or going for complete automation. At least that was the case until now - I'm happy to introduce compose-deploy. As the name suggests, it is a simple CLI tool that helps you with defining and running your deployments with ease.

Let's go through an example deployment to grasp how easy it actually is to deploy a simple hello-world service to our server. Our Compose file looks like the following

version: '3.7'
services:
demo:
build: .
image: brunoscheufler/demo-service:1.0.0
restart: on-failure
init: true
environment:
NODE_ENV: production

and our compose-deploy configuration contains

name: sample-deployment
targets:
- host: 'my-server-ip'
username: deploy-user
privateKeyFile: ./key/id_rsa
passphrase: 'SECRET PASSPHRASE'
composeFile: ./docker-compose.yml

Now we're ready to run the deployment!

$ compose-deploy
πŸ”¨ Building Docker images...
Building demo
Step 1/4 : FROM node:11-alpine
---> ebbf98230a82
Step 2/4 : WORKDIR /app
---> Using cache
---> 311a77c5bbda
Step 3/4 : COPY index.js /app
---> Using cache
---> 994482d9b3d0
Step 4/4 : CMD node index.js
---> Using cache
---> aa2745a3fd0c
Successfully built aa2745a3fd0c
Successfully tagged brunoscheufler/demo-service:1.0.0
🌎 Pushing Docker images...
Pushing demo (brunoscheufler/demo-service:1.0.0)...
The push refers to repository [docker.io/brunoscheufler/demo-service]
1.0.0: digest: sha256:<LONG_HASH> size: 1364
🎯 Deploying services...
πŸ’« Deploying to target 1 of 1...
πŸ“‘ Connecting to target server
πŸ₯ Connected! Copying Compose file...
Removing network sample_default
πŸ“¦ Pulling Docker images...
Pulling demo ... done
⚑️ Launching deployment...
Creating network "sample_default" with the default driver
Creating sample_demo_1 ... done
βœ… Deployment done!

And that's it! We've now deployed our demo service in less than thirty seconds. It works like magic ✨ If you're interested, head over to the repository and give it a try!