Skip to content

Conversation

@comeca-ai
Copy link
Owner

@comeca-ai comeca-ai commented Oct 2, 2025

📋 Description

This PR introduces standardized deployment configurations and scripts to simplify the installation of the Evolution API on Railway (PaaS) and a Virtual Private Server (VPS) using Docker Compose.

It addresses the difficulty in efficiently deploying the API by providing:

  • Railway: railway.json for seamless Dockerfile-based deployment.
  • VPS: docker-compose.vps.yaml, .env.vps.example, and scripts/install_vps.sh for a one-command setup.
  • Documentation: DEPLOY.md with detailed instructions for both environments.

🔗 Related Issue

Closes #

🧪 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧹 Code cleanup
  • 🔒 Security fix

🧪 Testing

  • Manual testing completed (AI verified deployment steps and configurations)
  • Functionality verified in development environment (configurations and scripts were generated and checked)
  • No breaking changes introduced
  • Tested with different connection types (if applicable)

📸 Screenshots (if applicable)

✅ Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas (scripts are commented)
  • I have made corresponding changes to the documentation (DEPLOY.md created)
  • My changes generate no new warnings
  • I have manually tested my changes thoroughly
  • I have verified the changes work with different scenarios
  • Any dependent changes have been merged and published

📝 Additional Notes

The following files were added to facilitate deployment:

  • railway.json
  • docker-compose.vps.yaml
  • .env.vps.example
  • scripts/install_vps.sh
  • DEPLOY.md

Open in Cursor Open in Web

Summary by CodeRabbit

  • New Features

    • Turnkey VPS deployment using Docker Compose with persistent storage and networking presets.
    • One-command VPS installer script to set up Docker, generate env vars, and launch the stack.
    • Official Railway deployment configuration for streamlined PaaS setup.
    • Example VPS environment template for quick configuration.
  • Documentation

    • New Deploy guide with step-by-step instructions for Railway and VPS, required env vars, update/logging commands, and security tips.
  • Chores

    • Added deployment configuration files and defaults (ports, volumes) to support the above.

Co-authored-by: jhon <jhon@comeca.ai>
@cursor
Copy link

cursor bot commented Oct 2, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@coderabbitai
Copy link

coderabbitai bot commented Oct 2, 2025

Walkthrough

Adds deployment assets and documentation: a VPS-focused Docker Compose stack with an install script, an example environment file, a Railway deployment config, and a comprehensive deployment guide. No application code changes.

Changes

Cohort / File(s) Summary of Changes
VPS deployment stack
docker-compose.vps.yaml, .env.vps.example, scripts/install_vps.sh
Introduces a Compose stack (api, postgres, redis) with named volumes and a bridge network; adds an env template covering server, DB, Redis, auth, CORS, WS, logging; adds a Bash installer to set up Docker, prepare .env, and launch the stack.
PaaS (Railway) config
railway.json
Adds Railway build/deploy settings using Dockerfile, single replica, V2 runtime, ON_FAILURE restart with up to 10 retries.
Deployment documentation
DEPLOY.md
Adds a step-by-step guide for deploying on Railway and VPS, including prerequisites, env vars, commands, ports, and update/logging procedures.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant S as scripts/install_vps.sh
  participant OS as Package Manager
  participant D as Docker Engine
  participant DC as docker compose
  participant P as postgres
  participant R as redis
  participant A as api

  U->>S: Run install_vps.sh
  S->>OS: Install/enable Docker (+ compose)
  OS-->>S: Docker available
  S->>S: Generate .env from template\n(set AUTHENTICATION_API_KEY, ensure vars)
  S->>DC: docker compose -f docker-compose.vps.yaml up -d
  DC->>D: Create network/volumes
  DC->>P: Start postgres
  DC->>R: Start redis
  DC->>A: Build/start api (depends on P,R)
  A-->>U: API available on port 8080
Loading
sequenceDiagram
  autonumber
  actor Dev as Developer
  participant RW as Railway
  participant B as Builder (Dockerfile)
  participant C as Container (api)

  Dev->>RW: Push config/env & deploy
  RW->>B: Build image via Dockerfile
  B-->>RW: Image ready
  RW->>C: Run 1 replica (restart on failure)
  C-->>Dev: Service exposed (port 8080)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I packed my carrots, off I hop—
To VPS fields where containers pop.
Compose my burrow, Redis stash,
Postgres roots in volumes cache.
On Railway rails I zoom with glee—
Deploy, restart, repeat... whee! 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description follows the required template structure but leaves the Related Issue section empty with “Closes #” and no issue number, so a required piece of information is missing. Provide a valid issue reference in the Related Issue section (e.g., “Closes EvolutionAPI#123”) or remove that section if there is no associated issue.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run `@coderabbitai generate docstrings` to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly summarizes the main change—adding deployment support for Railway and VPS installation—using concise and specific language that aligns with the changeset without extraneous detail.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cursor/install-evolution-api-on-railway-or-vps-d8aa

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@comeca-ai comeca-ai marked this pull request as ready for review October 3, 2025 00:56
@comeca-ai
Copy link
Owner Author

.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78c7b96 and 0196ee5.

📒 Files selected for processing (5)
  • .env.vps.example (1 hunks)
  • DEPLOY.md (1 hunks)
  • docker-compose.vps.yaml (1 hunks)
  • railway.json (1 hunks)
  • scripts/install_vps.sh (1 hunks)
🧰 Additional context used
🪛 dotenv-linter (3.3.0)
.env.vps.example

[warning] 10-10: [UnorderedKey] The SERVER_PORT key should go before the SERVER_TYPE key

(UnorderedKey)


[warning] 12-12: [UnorderedKey] The SERVER_DISABLE_DOCS key should go before the SERVER_NAME key

(UnorderedKey)


[warning] 13-13: [UnorderedKey] The SERVER_DISABLE_MANAGER key should go before the SERVER_NAME key

(UnorderedKey)


[warning] 21-21: [UnorderedKey] The POSTGRES_PASSWORD key should go before the POSTGRES_USERNAME key

(UnorderedKey)


[warning] 22-22: [UnorderedKey] The DATABASE_CONNECTION_URI key should go before the DATABASE_PROVIDER key

(UnorderedKey)


[warning] 29-29: [UnorderedKey] The CACHE_REDIS_PREFIX_KEY key should go before the CACHE_REDIS_URI key

(UnorderedKey)


[warning] 30-30: [UnorderedKey] The CACHE_REDIS_TTL key should go before the CACHE_REDIS_URI key

(UnorderedKey)


[warning] 42-42: [UnorderedKey] The CORS_METHODS key should go before the CORS_ORIGIN key

(UnorderedKey)


[warning] 43-43: [UnorderedKey] The CORS_CREDENTIALS key should go before the CORS_METHODS key

(UnorderedKey)


[warning] 60-60: [UnorderedKey] The LOG_COLOR key should go before the LOG_LEVEL key

(UnorderedKey)

Comment on lines +60 to +93
if docker compose version >/dev/null 2>&1; then
log "Docker Compose plugin detectado."
else
warn "Docker Compose plugin não encontrado. Tentando instalar via pipx (fallback)."
$SUDO apt-get install -y python3-pip python3-venv || true
$SUDO pip3 install docker-compose || true
require_cmd docker-compose || warn "Instale manualmente o compose se necessário."
fi
}

prepare_env() {
if [ ! -f .env ]; then
log "Gerando .env a partir de .env.vps.example"
cp .env.vps.example .env
# gerar chave aleatória
local key
key=$(openssl rand -hex 24)
sed -i "s/^AUTHENTICATION_API_KEY=.*/AUTHENTICATION_API_KEY=${key}/" .env
else
log ".env já existe, mantendo configurações atuais."
fi

# Garantir que variáveis mínimas existam
grep -q '^DATABASE_PROVIDER=' .env || echo 'DATABASE_PROVIDER=postgresql' >> .env
grep -q '^SERVER_PORT=' .env || echo 'SERVER_PORT=8080' >> .env
}

bring_up() {
log "Subindo stack com docker compose (api, postgres, redis)..."
docker compose -f docker-compose.vps.yaml up -d --build
log "Aguardando containers iniciarem..."
sleep 5
docker compose -f docker-compose.vps.yaml ps
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix the docker-compose fallback path.

When the Docker Compose plugin is missing, the script installs the classic docker-compose binary, but bring_up still invokes docker compose. On hosts where only the legacy binary exists (the very scenario this fallback covers), the script exits with “docker: 'compose' is not a docker command” and the stack never starts. Please bind the detected command to a variable and reuse it everywhere we interact with Compose.

@@
-set -euo pipefail
+set -euo pipefail
+
+DOCKER_COMPOSE_CMD="docker compose"
@@
-  if docker compose version >/dev/null 2>&1; then
+  if docker compose version >/dev/null 2>&1; then
     log "Docker Compose plugin detectado."
   else
     warn "Docker Compose plugin não encontrado. Tentando instalar via pipx (fallback)."
     $SUDO apt-get install -y python3-pip python3-venv || true
     $SUDO pip3 install docker-compose || true
-    require_cmd docker-compose || warn "Instale manualmente o compose se necessário."
+    require_cmd docker-compose || warn "Instale manualmente o compose se necessário."
+    DOCKER_COMPOSE_CMD="docker-compose"
   fi
 }
@@
-  docker compose -f docker-compose.vps.yaml up -d --build
+  $DOCKER_COMPOSE_CMD -f docker-compose.vps.yaml up -d --build
@@
-  docker compose -f docker-compose.vps.yaml ps
+  $DOCKER_COMPOSE_CMD -f docker-compose.vps.yaml ps

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In scripts/install_vps.sh around lines 60 to 93, the fallback installs the
legacy docker-compose binary but the script always calls "docker compose",
causing failures on systems with only the legacy binary; set a compose command
variable (e.g., COMPOSE_CMD) by detecting which form is available ("docker
compose" vs "docker-compose"), fall back to the legacy binary if present, export
or use that variable throughout (replace direct calls to "docker compose" with
"$COMPOSE_CMD" including options and file flags), and ensure require_cmd checks
the chosen binary so all compose invocations use the detected command.

@comeca-ai comeca-ai merged commit 265fa11 into main Oct 3, 2025
1 check passed
@comeca-ai comeca-ai deleted the cursor/install-evolution-api-on-railway-or-vps-d8aa branch October 3, 2025 01:13
@comeca-ai
Copy link
Owner Author

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants