惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园_首页
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
ThreatConnect
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
H
Help Net Security
T
Threat Research - Cisco Blogs
Blog — PlanetScale
Blog — PlanetScale
A
Arctic Wolf
G
Google Developers Blog
量子位
U
Unit 42
I
InfoQ
V
V2EX
F
Fox-IT International blog
P
Privacy & Cybersecurity Law Blog
V
Visual Studio Blog
J
Java Code Geeks
大猫的无限游戏
大猫的无限游戏
C
CERT Recently Published Vulnerability Notes
博客园 - 三生石上(FineUI控件)
T
The Exploit Database - CXSecurity.com
T
Tailwind CSS Blog
SecWiki News
SecWiki News
Know Your Adversary
Know Your Adversary
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
The Hacker News
The Hacker News
Project Zero
Project Zero
Application and Cybersecurity Blog
Application and Cybersecurity Blog
月光博客
月光博客
Recent Commits to openclaw:main
Recent Commits to openclaw:main
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
GRAHAM CLULEY
C
Cisco Blogs
I
Intezer
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
Recorded Future
Recorded Future
T
Tenable Blog
W
WeLiveSecurity
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
T
The Blog of Author Tim Ferriss
www.infosecurity-magazine.com
www.infosecurity-magazine.com
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
PCI Perspectives
PCI Perspectives

DEV Community

AI May Do for FOSS What 30 Years of Idealism Couldn't I Built an AI-Powered PC Monitor in Python. 28 Strangers Shaped Its Brain. PC Workman 1.7.6 Voices from the Community: Forewords and Praise for 'Docker and Kubernetes Security' I gave up on making my AI builder write good media queries Building software in C#: part 1 - history. Why Most DNS Audit Tools Don't Give You the Actual Fix (And Why We Do) Check out my latest project 10 Most Important Things You Should Learn in Lean 4 How I Automated My Obsidian Vault with Claude — It Now Works the Night Shift The hidden cost of cloud GPU training: egress, idle time, and lock-in Control SwiftUI and Compose State Synchronously with Worklets in Expo UI We Didn’t Just Train AI on the Internet. We Started Training It on Itself. Review: Bazel in Depth (Richard Johnson) Centralized vs. Decentralized: Why Modern Collaborative Tools choose CRDTs Seeking Advice: Building AI tools for the (suffering) nonprofit community RabbitMQ Explained: How It Works, How It Differs from Kafka, and Where It Fits in Real Systems Alert policies people actually follow (spoiler: fewer routes win) React Native и App Store — почему похожие приложения получают отказ Injeção e Inversão de Dependência e como o NestJS gerencia tudo isso SOLID Principles in C# — I Refactored 60 Ugly Lines, One Rule at a Time Global Strategic Analysis: Structural Tensions in the RAM and Storage Market in 2026 The End of the Lone Coder: Why Future Developers Will Be AI Orchestrators (and how to get started with PrestaShop) Beyond Function Calling: How the Model Context Protocol (MCP) Turns AI Agents into Self-Evolving Systems Build a Chrome extension that switches localhost/staging/production URLs AI Is Useful. But It Doesn't Think Like We Do. Build a $0/month contact form backend with Google Sheets The x3.16 Developer | Part 1 bQuery.js Grows Up: From Tiny jQuery Tribute to a Full-Stack Framework — and a Brand New Home at bquery.js.org 🎉 I shipped super-time-tracker-ui, a local web UI for my CLI time sheets Before SQL, We Had to Tell Computers Everything. Then One Idea Changed That Forever. Why Distributed Transactions Fail and How the Outbox Pattern Helps Winner Announcement Delayed for the Gemma 4 Challenge AI writes your code. Does anyone on your team actually understand it? I've been in incident calls where brilliant engineers went silent. I'm calling it Cognitive Debt — and it's accumulating silently on every team right now. 🔹 Configure network routing Inside the New ESP32 Pocket Computer Underground The Attack Vectors Nobody Tells You About: Hardening LLM Apps Against Prompt Injection Claude Sonnet 4.5 vs 4.6: What Changed and Which Should You Use? Who's watching what your AI agent does when you're not looking? The Bug Under the Bug Under the Bug: A Three-Cycle Debug Story How to get live 3D print pricing in Google Sheets with one formula FiXiY - Find X in Y I made my Markdown Editor "AI-Ready": MarkSmith v0.3.0 Appendix: Live System Output Production DevSecOps Pipeline — The Complete Day-2 Operations Runbook Anyone Can Make Software Now. But When Does A Side Project Become Production Ready? Feedback Latency Is the Agent's IQ How to Integrate AI and LLMs into Production Web Apps (Lessons from the Field) I kept forgetting what subscriptions I was paying for, so I built something about it Human-in-the-Loop AI Workflow Automation with Make, FastAPI, OpenAI, and Monday CRM Meet phpvm: The PHP Version Manager for Linux (v2.5.1 Released) [Boost] The Hidden Cost of Context Switching How to Prepare for a Technical Data Engineer Interview I built a local MCP server that gives Claude Code real PR context — 33s reviews instead of 90s How I built AgentRAM: a memory API for AI agents without a vector DB AI, Pig Butchering, and the New Frontier of Scams: Why Scammers Are Becoming Developers Journey Begins: Google Cloud Get Certified Program Edition 2 (2026) I Vibe-Coded an App in a Weekend. Three Weeks Later I Couldn't Explain It. Feeding Raw HTML to Your LLM Is a Token Tax. I Measured It on 10 Real Pages — Median 7.4 , and It Hits Every Scheduled Run 22/30 Days System Design Questions Beyond Strict Mode: 5 Advanced TSConfig Settings for Bulletproof TypeScript The bug I kept seeing in math practice: right answers that were too slow gotracer: Turn Go Execution Traces into Actionable Findings Forget Python: Why PHP is the Real Future of AI for the Web Stop Reinventing the Wheel: 5 Hidden Gems in PrestaShop's Tools.php File AI Tools & Products Radar — May 28, 2026 New Benchmark Reveals Hidden Trade-offs in AI Model Tuning Methods What I Learned Building My First Chrome Extension for Google Calendar Trider – The AI Habit Tracker That Actually Gets You (Free, No Ads) 4 Best AI TTS APIs in 2026 Claude Opus 4.8: What Developers Need to Know About Anthropic's New Flagship Claude Opus 4.8: What Developers Need to Know About Anthropic's New Flagship Full Stack Developer Looking for Internship Opportunities How Microservices Talk to Each Other Using WebClient After burning through tens of billions of tokens, I built an Android-like OS that runs entirely in the browser The PrestaShop Modules "Jungle": An Unexpected Opportunity for Your Site? I Ship One AI Testing Feature Every Day — Here's What 6 Days Looks Like Only 2 of 128 YC-backed dev tools companies block unchecked merges Read environment variables from .env file in Angular PrestaShop Added an AI Onboarding System Directly to Its Repo The AI Control Plane Is Becoming the New Shadow IT How-To Spec-Driven AI Development Veltrix Events Were a Disaster Until We Fixed One Crucial Thing Phone-as-keyboard for any USB host — building a driverless HID bridge PrestaShop Development: Is Documentation Really the Problem? Python List Methods Explained Simply (Add, Remove, Sort) Impostor Syndrome in Tech - The Honest Version Nobody Posts About I Built a Tool to Stop Guessing LLM API Costs. Here Is What I Learned. Constraint Decay: Why Your AI Coding Agent Passes Tests But Breaks Production KairoDB-Human-Readable Databases Your best pull request could be a -500 (and that's seniority) I Built a Terminal Typing App Because I Was Tired of Leaving My Terminal Sending SMS from AWS Lambda Markdown to PDF: 8 methods compared (and why most of them disappoint) Coordinar deploys de frontend y backend sin orquestado, usando Github Actions I had to restore an entire database just to recover one deleted row The Sovereign Vault: Building High-Integrity AI with MCP & Local Vision I Built a Lightweight Python RAG Orchestrator That Works with SQLite, PGVector and Qdrant Redis — The Engine of Instant Gratification The Project I Couldn’t Finish 2 Years Ago - Notebook for ChatGPT
I Deploy to Docker Swarm from GitHub Actions — Here's the Setup That Actually Works
Sulthon Zain · 2026-05-29 · via DEV Community

If you've ever tried to set up continuous deployment to a remote Docker host, you know the pain. GitHub Actions is great for CI — build, test, done. But deploying to a remote server? That's where things get messy.

Most tutorials hand you a 200-line shell script with ssh hacks, scp gymnastics, and prayer. I got tired of that, so I packaged it into a reusable GitHub Action that handles Docker Compose and Docker Swarm deployments over SSH.

Here's how it works and how to set it up in under 10 minutes.

The Problem

You have a VPS (or a bare-metal server) running Docker. You want GitHub Actions to:

  1. Build your images (or pull them from a registry)
  2. SSH into your server
  3. Deploy using docker-compose up or docker stack deploy
  4. Clean up old files

Without leaking SSH keys everywhere or writing bespoke deployment scripts per project.

The Action: docker-remote-deployment-action

github.com/sulthonzh/docker-remote-deployment-action

It's a GitHub Action available on the Marketplace that does exactly this. It supports two deployment modes:

  • docker-compose — runs docker-compose on the remote host
  • docker-swarm — runs docker stack deploy for Swarm services

Both via SSH, both from your existing docker-compose.yml.

The Minimal Setup

1. Add your SSH keys to GitHub Secrets

In your repo → Settings → Secrets and variables → Actions, add:

  • SSH_PRIVATE_KEY — your private key for the server
  • SSH_PUBLIC_KEY — the corresponding public key

2. Create the workflow file

# .github/workflows/deploy.yml
name: Deploy

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Deploy to server
        uses: sulthonzh/docker-remote-deployment-action@v1
        with:
          remote_docker_host: deploy@your-server.com
          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

Enter fullscreen mode Exit fullscreen mode

Push to main → your service deploys. That's it.

Docker Swarm Mode

If you're running a Swarm cluster, switch the mode and add the stack name:

- name: Deploy to Swarm
  uses: sulthonzh/docker-remote-deployment-action@v1
  with:
    remote_docker_host: deploy@your-server.com
    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

Enter fullscreen mode Exit fullscreen mode

This will:

  1. Copy your docker-compose.yaml to /opt/deployments/myapp/ on the server
  2. Run docker stack deploy -c docker-compose.yaml myapp
  3. Keep the last 5 deployment files (auto-cleanup old ones)

Feature Breakdown

copy_stack_file: true — Deploy from the server

When enabled, the Action copies your compose file to a configurable path on the remote host before deploying. This is useful when:

  • Your compose file references local build contexts
  • You want deployment history on the server
  • You need to inspect the compose file on the host later

Combined with keep_files: N, it auto-prunes old deployment directories. No manual cleanup.

pull_images_first: true — Pull before deploy

If your compose file references images from a private registry:

pull_images_first: true
docker_registry_username: ${{ secrets.REGISTRY_USER }}
docker_registry_password: ${{ secrets.REGISTRY_PASS }}

Enter fullscreen mode Exit fullscreen mode

The Action logs into your registry and pulls images before deploying. Works with any Docker-compatible registry.

docker_prune: true — Automatic cleanup

Adds a docker system prune -f after deployment. Useful on small VPS instances where disk space is precious.

pre_deployment_command_args — Run commands before deploy

Need to run migrations or health checks before deploying?

pre_deployment_command_args: "docker exec myapp_web bundle exec rake db:migrate"

Enter fullscreen mode Exit fullscreen mode

Runs any command on the remote host before the deployment step.

A Real-World Example: Full Pipeline

Here's a complete workflow that builds, pushes, and deploys:

name: Build and Deploy

on:
  push:
    branches: [main]

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Build and push
        uses: docker/build-push-action@v6
        with:
          context: .
          push: true
          tags: myuser/myapp:${{ github.sha }}

      - name: Update image tag in compose file
        run: |
          sed -i "s|image: myuser/myapp:.*|image: myuser/myapp:${{ github.sha }}|" docker-compose.yml

      - name: Deploy
        uses: sulthonzh/docker-remote-deployment-action@v1
        with:
          remote_docker_host: deploy@myserver.com
          ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
          ssh_public_key: ${{ secrets.SSH_PUBLIC_KEY }}
          deployment_mode: docker-compose
          copy_stack_file: true
          deploy_path: /opt/myapp
          stack_file_name: docker-compose.yml
          keep_files: 3
          pull_images_first: true
          docker_registry_username: ${{ secrets.DOCKERHUB_USERNAME }}
          docker_registry_password: ${{ secrets.DOCKERHUB_TOKEN }}
          args: up -d --remove-orphans

Enter fullscreen mode Exit fullscreen mode

This gives you a full CI/CD pipeline: commit → build → push → deploy. No Jenkins, no GitLab Runner, no self-hosted agent. Just GitHub Actions SSHing into your server.

Security Notes

A few things to keep in mind:

  • Use a dedicated deploy user on your server, not root. Create a user that only has Docker permissions.
  • Restrict SSH keys — the deploy key should only work for Docker-related commands.
  • Use GitHub Secrets — never hardcode keys in your workflow files.
  • Rotate keys if they ever appear in logs (the Action masks secrets, but be careful with set -x in pre-deployment commands).

When This Shines

This setup is ideal for:

  • Solo devs / small teams deploying to a single VPS
  • Side projects that don't need Kubernetes
  • Staging environments that auto-deploy on push
  • Hobby infrastructure where you want CI/CD without the complexity of ArgoCD or Flux

If you're running 50 microservices on EKS, this isn't for you. If you're deploying a few containers to a $5/month DigitalOcean droplet, this is exactly what you need.

What's Next

The Action is stable and production-ready at v1.0.0. It's adapted from earlier work by wshihadeh and TapTap21, with improvements for modern GitHub Actions.

Star it, try it, open issues if something doesn't work. That's how open source grows.


Built this while deploying side projects at quadbyte. More dev tools coming.