diff --git a/README.md b/README.md index 5afe6eb..9761a4f 100644 --- a/README.md +++ b/README.md @@ -101,10 +101,15 @@ Inspect the dry-run logs before enabling writes. Dry-run logs include the Tiny r Build and run the worker once: ```sh -docker compose run --rm production-orders-sync +docker build -t production-orders-sync:local . +PRODUCTION_ORDERS_SYNC_IMAGE=production-orders-sync:local docker compose run --rm production-orders-sync ``` -The included `postgres` service is only a local example. In normal deployment, set `DATABASE_URL` to the existing Graphs Postgres database. +The optional local Postgres example is in `docker-compose.local-db.yml`. In normal deployment, set `DATABASE_URL` to the existing Graphs Postgres database. + +```sh +docker compose -f docker-compose.local-db.yml up -d postgres +``` ## Gitea Actions + Portainer diff --git a/docker-compose.local-db.yml b/docker-compose.local-db.yml new file mode 100644 index 0000000..0eb29a5 --- /dev/null +++ b/docker-compose.local-db.yml @@ -0,0 +1,14 @@ +services: + postgres: + image: postgres:16-alpine + environment: + POSTGRES_DB: graphs + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + ports: + - "5432:5432" + volumes: + - production-orders-sync-postgres:/var/lib/postgresql/data + +volumes: + production-orders-sync-postgres: diff --git a/docker-compose.yml b/docker-compose.yml index 7d3dadd..d789b30 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,27 +1,26 @@ services: production-orders-sync: - build: . + image: ${PRODUCTION_ORDERS_SYNC_IMAGE:-gitea.blyzer.com.br/blyzer/production-order-tiny:latest} container_name: production-orders-sync - env_file: - - .env environment: + NODE_ENV: production + TINY_API_TOKEN: ${TINY_API_TOKEN:-} + DATABASE_URL: ${DATABASE_URL:-} + TINY_API_BASE_URL: ${TINY_API_BASE_URL:-https://api.tiny.com.br/api2} + TINY_LIST_ENDPOINT: ${TINY_LIST_ENDPOINT:-ordens.producao.pesquisa.php} + TINY_DETAIL_ENDPOINT: ${TINY_DETAIL_ENDPOINT:-ordem.producao.obter.php} + TINY_HTTP_METHOD: ${TINY_HTTP_METHOD:-POST} + TINY_START_DATE_PARAM: ${TINY_START_DATE_PARAM:-dataInicial} + TINY_END_DATE_PARAM: ${TINY_END_DATE_PARAM:-dataFinal} + TINY_DATE_FORMAT: ${TINY_DATE_FORMAT:-DD/MM/YYYY} + TINY_FETCH_DETAILS: ${TINY_FETCH_DETAILS:-false} TINY_REQUEST_DELAY_MS: ${TINY_REQUEST_DELAY_MS:-5000} + TINY_BLOCK_RETRY_MS: ${TINY_BLOCK_RETRY_MS:-60000} + TINY_MAX_RETRIES: ${TINY_MAX_RETRIES:-3} + SYNC_MODE: ${SYNC_MODE:-backfill} + SYNC_TIME_ZONE: ${SYNC_TIME_ZONE:-America/Sao_Paulo} + RECENT_SYNC_DAYS: ${RECENT_SYNC_DAYS:-2} + SYNC_START_DATE: ${SYNC_START_DATE:-} + SYNC_END_DATE: ${SYNC_END_DATE:-} DRY_RUN: ${DRY_RUN:-false} restart: "no" - - # Example only. In production, point DATABASE_URL at the existing Graphs Postgres. - postgres: - image: postgres:16-alpine - profiles: - - local-db - environment: - POSTGRES_DB: graphs - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - ports: - - "5432:5432" - volumes: - - production-orders-sync-postgres:/var/lib/postgresql/data - -volumes: - production-orders-sync-postgres: