-
Couldn't load subscription status.
- Fork 1
Install evolution api on railway or vps #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install evolution api on railway or vps #1
Conversation
Co-authored-by: jhon <jhon@comeca.ai>
|
Cursor Agent can help with this pull request. Just |
WalkthroughAdds 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
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
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)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests
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. Comment |
|
. |
There was a problem hiding this 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
📒 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)
| 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 | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 psCommittable 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.
|
. |
📋 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.jsonfor seamless Dockerfile-based deployment.docker-compose.vps.yaml,.env.vps.example, andscripts/install_vps.shfor a one-command setup.DEPLOY.mdwith detailed instructions for both environments.🔗 Related Issue
Closes #
🧪 Type of Change
🧪 Testing
📸 Screenshots (if applicable)
✅ Checklist
DEPLOY.mdcreated)📝 Additional Notes
The following files were added to facilitate deployment:
railway.jsondocker-compose.vps.yaml.env.vps.examplescripts/install_vps.shDEPLOY.mdSummary by CodeRabbit
New Features
Documentation
Chores