当前位置: 首页 > Skill >

一键部署到服务器

一键部署到服务器

一键部署到服务器

一条命令把开源项目部署上服务器:自动克隆/上传代码、生成 Docker Compose、初始化环境并拉起容器,零 Docker 基础也能一键上线。

1.0.0 2026.11.10 462
获取Skill文件查看使用说明
作 者:苏川 许可证: 更新时间:2026.11.10
本文目录展开

One-Click Deploy (OSS → remote server via Docker Compose)

Deploy any open-source project to a target Linux server with a single orchestrated run: clone-or-upload → auto-compose → transfer → docker compose up.

When to use

  • User says "把 XX 部署到服务器 / 一键部署 / deploy XX to my server".
  • User provides a git URL (GitHub/GitLab/Gitee) or a local project folder and a target server (host, user, SSH key).
  • User wants a reproducible, containerized deployment without hand-rolling Dockerfiles each time.

Design decisions (fixed by this skill)

  • Transport: SSH with a private key (passwordless). No passwords in scripts.
  • Runtime: Docker Compose (v2 plugin preferred, v1 fallback).
  • Sources: Either --git-url (clone on local staging) or --local-path (upload). Both supported.
  • Compose: Use the repo's own compose file if present; otherwise auto-generate from the detected stack (Node / Python / Go / static). Rust & JVM are NOT auto-generated — ask the user for a Dockerfile/compose.
  • Provisioning: Optional (--provision) and idempotent — installs docker, git, curl, firewall rules, and adds the user to the docker group.

Workflow

1. Collect required inputs

Ask the user (or read from conversation) for:

Input Flag Notes
Server host --host IP or domain
SSH user --user e.g. ubuntu, root
SSH private key --key Path on THIS machine (not .pub)
Project source --git-url or --local-path Mutually exclusive
Project name --project Optional; defaults to repo/dir name
Remote dir --deploy-dir Optional; default ~/deploy/<project>
Env vars --env K=V Repeatable
Port mapping --ports H:C Repeatable; default 8080:8080
Branch --git-branch Optional; default main
Provision --provision Add to install docker/firewall on a bare server
Force recreate --force Recreate containers

If any of host / user / key / source is missing, ask the user before running.

2. Locate the skill scripts

scripts/deploy.sh, scripts/provision.sh, scripts/gen_compose.py live beside this SKILL.md. Resolve their absolute path via the skill directory.

3. Run the deploy

bash <skill>/scripts/deploy.sh 
  --host <HOST> --user <USER> --key <KEY> 
  --git-url <URL>            # OR --local-path <DIR>
  --ports 80:8080 
  --env NODE_ENV=production 
  --provision               # include on a fresh/bare server

The script prints a 6-step progress log and a final summary (access URL, how to view logs, how to stop / redeploy).

4. Handle generation failures

If gen_compose.py exits non-zero (Rust/JVM/unknown stack), do NOT retry the script blindly. Instead:

  • Tell the user the stack wasn't auto-detectable, and ask them to either (a) provide/commit a docker-compose.yml + Dockerfile in the repo, or (b) paste a known-good compose file for you to drop into the staging dir.

5. Report

Summarize: deployed project, server, access URL, and the exact commands for logs / stop / redeploy. Point to references/troubleshooting.md if anything failed mid-way.

Reference material

  • references/ssh-setup.md — generate keys, copy pub key, verify passwordless SSH.
  • references/compose-cookbook.md — detection rules and how to customize output.
  • references/troubleshooting.md — connection / provision / build failure fixes.

Notes & safety

  • Private keys stay local; only the public key ever touches the server.
  • Re-running re-pulls / re-uploads fresh code and rebuilds — safe to repeat.
  • Cloud security groups are separate from OS firewall; the user may still need to open ports at the provider level.
  • Never hardcode secrets; pass them via --env and they land in a server-side .env that is git-ignored by convention.

相关文章

更多
基于Docker Compose部署Grafana与Prometheus监控体系

本文介绍如何使用Docker Compose编排InfluxDB、Node Exporter等组件构建监控环境。通过配置prometheus.yml定义抓取目标,利用alertmanager.yml设置邮件告警路由,并编写node_down.yml规则文件实现实例宕机及资源阈值监控。结合Grafana仪表盘可直观展示系统状态。

2026.01.18 995
SkyWalking在Docker中的部署与Agent集成指南

本文介绍如何在Docker环境中部署SkyWalking APM系统,后端存储选用Elasticsearch 7.5.1。通过修改系统参数、持久化数据目录以及使用docker-compose进行服务编排,实现OAP服务器与UI界面的快速启动。最后演示如何将SkyWalking Agent注入到Java应用中,完成从基础设施到应用层的链路追踪配置。

2026.06.06 994
基于Docker-Compose的PHP项目部署完整指南

本文详细演示了如何使用 Docker Compose 编排 Nginx、PHP-FPM 和 MySQL 服务以部署 PHP 项目。核心步骤包括编写自定义 Dockerfile 安装 GD、Redis 等扩展,配置 docker-compose.yml 定义网络与卷挂载,设置 Nginx 反向代理规则,以及修改 MySQL 用户权限以允许远程访问。最后通过启动容器并创建测试脚本验证各组件间的连通性。

2025.03.25 993
Docker利用单个镜像映射到多个端口操作

针对资源服务器需多实例运行但复制缓慢的问题,可通过修改docker-compose.yml中的ports配置,将同一个Docker镜像映射到不同宿主机端口以启动多个容器实例。此外,结合Docker Compose工具,可定义YAML文件统一编排多个服务(如Apache、Nginx及Haproxy),实现容器的隔离运行与负载均衡。

2026.06.29 990
基于Docker Compose搭建LNMPR开发环境详解

本文介绍如何使用Docker Compose快速搭建包含PHP 8.1、Nginx 1.22、MySQL 8.0、MongoDB 6.0及Redis 6.0的完整开发环境。通过定义docker-compose.yml配置文件,实现多容器服务的隔离运行与一键启动,支持Swoole等常用扩展,并提供详细的安装、配置及故障排除步骤。

2025.12.02 938
基于Docker Compose的RuoYi项目部署实战指南

本文详细记录了在CentOS 7环境下,使用Docker Compose编排部署RuoYi微服务项目的完整流程。内容涵盖Docker及Compose的安装、多模块镜像构建、配置文件挂载、容器间网络通信设置,以及网卡冲突、远程连接失败和Redis持久化文件权限等常见错误的解决方案。通过分步操作指导,帮助开发者快速实现本地开发环境到线上生产环境的平滑迁移。

2025.05.17 929
Skill 文件
  • SKILL.md
    • One-Click Deploy (OSS → remote server via Docker Compose)
    • When to use
    • Design decisions (fixed by this skill)
    • Workflow
      • 1. Collect required inputs
      • 2. Locate the skill scripts
      • 3. Run the deploy
      • 4. Handle generation failures
      • 5. Report
    • Reference material
    • Notes & safety
  • 项目或源文件

相关 Skill

更多
Docker Compose Docker Compose 使用正确的依赖处理、网络和卷管理来定义多容器应用。
initial-traefik initial-traefik 初始化并配置 Traefik 反向代理,使用 Docker。安装 Traefik,配置 Docker Compose,设置基于路径前缀或主机名的服务路由。
InspirAI Deploy InspirAI Deploy 智能部署工具——自动检测部署策略,预检查、发布、监控一体化。支持 K8s/Helm、Docker Compose、Vercel、Fly.io。触发词:'部署', 'deploy', '发布', '上线', '预检查', '部署监控', 'helm upgrade', 'docker compose...
Huo15 Searxng Huo15 Searxng SearXNG 自托管搜索引擎一键部署 - Docker Compose + OpenClaw 配置自动化 (v1.2.1)
Lazydocker Lazydocker lazydocker——Docker 与 Docker Compose 的终端 UI 管理工具