OmniLink API
Instalação

Docker local

Suba a OmniLink API com a imagem do Docker Hub, Postgres e Redis.

A OmniLink API é distribuída como imagem Docker. Você não precisa do código-fonte.

Imagem:

automacaodebaixocusto/omnilink-api:latest

Arquiteturas: linux/amd64 e linux/arm64 (a mesma tag).

A mesma imagem roda a API e o worker Celery. Postgres e Redis sobem à parte.

1. Arquivo Compose

Salve como docker-compose.yml (usa a imagem do Hub, não faz build):

services:
  api:
    image: automacaodebaixocusto/omnilink-api:latest
    container_name: omnilink-api
    env_file:
      - .env
    environment:
      DATABASE_URL: postgresql+psycopg://omnilink:omnilink@postgres:5432/omnilink
      REDIS_URL: redis://redis:6379/0
      CELERY_BROKER_URL: redis://redis:6379/1
      CELERY_RESULT_BACKEND: redis://redis:6379/2
    ports:
      - "8000:8000"
    command: sh -c "PYTHONPATH=/app alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000"
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started

  worker:
    image: automacaodebaixocusto/omnilink-api:latest
    container_name: omnilink-worker
    env_file:
      - .env
    environment:
      DATABASE_URL: postgresql+psycopg://omnilink:omnilink@postgres:5432/omnilink
      REDIS_URL: redis://redis:6379/0
      CELERY_BROKER_URL: redis://redis:6379/1
      CELERY_RESULT_BACKEND: redis://redis:6379/2
    command: celery -A app.workers.celery_app.celery_app worker --loglevel=INFO
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started

  postgres:
    image: postgres:16
    container_name: omnilink-postgres
    environment:
      POSTGRES_DB: omnilink
      POSTGRES_USER: omnilink
      POSTGRES_PASSWORD: omnilink
    ports:
      - "5432:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U omnilink -d omnilink"]
      interval: 5s
      timeout: 3s
      retries: 10

  redis:
    image: redis:7
    container_name: omnilink-redis
    ports:
      - "6379:6379"

volumes:
  pgdata:

2. Arquivo .env

Crie um .env ao lado do compose. Em APP_ENV=development, ENCRYPTION_KEY e WEBHOOK_SIGNING_SECRET vazios usam defaults internos. METRICS_TOKEN vazio deixa /metrics e /health/diagnostics abertos.

Exemplo mínimo:

APP_ENV=development
APP_DEBUG=false
DEFAULT_AFFILIATE_TAG=afiliadosLAB
# ENCRYPTION_KEY=
# WEBHOOK_SIGNING_SECRET=
# METRICS_TOKEN=

O compose sobrescreve DATABASE_URL e as URLs do Redis para os hostnames postgres e redis (não use localhost dentro dos containers).

Detalhes de cada variável: Variáveis de ambiente.

3. Subir

docker pull automacaodebaixocusto/omnilink-api:latest
docker pull postgres:16
docker pull redis:7

docker compose up -d
docker compose ps

Parar (mantém o volume do Postgres):

docker compose down

Portas

ServiçoHostContainer
API80008000
Postgres54325432
Redis63796379
Worker

Testar

curl -X GET "http://localhost:8000/health"
{"status":"ok"}
curl -X GET "http://localhost:8000/health/ready"
{"status":"ready","checks":{"database":"ok","redis":"ok"}}

Se banco ou Redis falhar: 503 com detail.status=unhealthy.

Rotas de negócio precisam do header x-api-key — veja Autenticação.

Produção com Swarm: Docker Swarm.

On this page