Streamlining Docker Swarm and Compose Deployments via GitHub Actions
These articles are AI-generated summaries. Please check the original sources for full details.
I Deploy to Docker Swarm from GitHub Actions — Here’s the Setup That Actually Works
Sulthon Zainul Habib has released the docker-remote-deployment-action for GitHub Actions. This tool eliminates the need for 200-line shell scripts by automating SSH, SCP, and Docker deployment commands.
Why This Matters
Standard CI pipelines excel at building and testing but often fail at the ‘last mile’ of remote deployment, forcing engineers to rely on fragile, bespoke SSH hacks and manual file transfers. This creates a technical gap where deployment logic is decoupled from version control, increasing the risk of configuration drift and security leaks when managing private keys across multiple environments.
Key Insights
- The
docker-remote-deployment-actionsupports two distinct modes:docker-composefor standard containers anddocker-swarmfor stack deployments (v1.0.0). - Automated cleanup can be achieved via
keep_files: N, which prunes old deployment directories on the remote host to prevent disk exhaustion. - Pre-deployment hooks are supported via
pre_deployment_command_args, enabling critical tasks like database migrations (e.g., running rake db:migrate) before service updates. - Disk space management on small VPS instances is handled through an optional
docker_prune: trueflag that executes a system prune after deployment.
Working Examples
Minimal GitHub Action workflow setup for Docker Compose deployment.
- name: Deploy to server
uses: sulthonzh/docker-remote-deployment-action@v1
with:
remote_docker_host: [email protected]
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
deployment_mode: docker-compose
stack_file_name: docker-compose.yml
args: up -d
Configuration for deploying to a Docker Swarm cluster with file persistence and auto-cleanup.
- name: Deploy to Swarm
uses: sulthonzh/docker-remote-deployment-action@v1
with:
remote_docker_host: [email protected]
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
deployment_mode: docker-swarm
copy_stack_file: true
deploy_path: /opt/deployments/myapp
stack_file_name: docker-compose.yaml
keep_files: 5
args: myapp
Practical Applications
References:
github.com/sulthonzh/docker$-remote$-deployment$-action$
Continue reading
Next article
Why Switching to Tailwind CDN Solves LLM Responsive Design Failures
Related Content
Streamlining DevOps: Automatic HTTPS Reverse Proxy with Caddy and Docker Compose
This technical guide demonstrates how to implement an automatic HTTPS reverse proxy using Caddy and Docker Compose in a single configuration file. It simplifies TLS management for containerized applications, ensuring secure communication with minimal manual overhead for developers and engineers.
Optimize Docker Compose Workflows with Profiles, Extends, and Depends_on
Streamline development environments by using Docker Compose profiles for optional services and the long-syntax depends_on for health-checked startup orchestration.
Docker Disk Exhaustion: Reclaiming 56 GB and Automating Cleanup
Learn how a Docker-driven VPS hit 100% disk usage, reclaiming 56 GB by pruning build caches and images, and implementing a systemd automation.