From f998465c2dff5b60cdfb96e98ba6b387a6123134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20D=C3=B6ll?= Date: Tue, 3 Sep 2024 06:41:14 +0000 Subject: [PATCH] chore: change to postgres --- docker-compose.yml | 40 ++++++++++++++++++++++++++-------------- internal/cfg/config.go | 6 +++--- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 415ae40..56edf54 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,29 +1,35 @@ services: - crdb: - restart: always - image: cockroachdb/cockroach:latest-v24.1 + postgres: + image: postgres:14 + container_name: postgres + networks: + - service-lens ports: - - "26257:26257" - - "8082:8080" - command: start-single-node --insecure + - "5432:5432" + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=password + - POSTGRES_DB=default volumes: - - "crdb:/cockroach/cockroach-data" + - pg:/var/lib/postgresql/data healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:8080/health?ready=1"] - interval: 3s - timeout: 3s + test: [ "CMD-SHELL", "pg_isready -U postgres" ] + interval: 5s + timeout: 5s retries: 5 migrate: depends_on: - crdb: + postgres: condition: service_healthy image: openfga/openfga:latest container_name: migrate command: migrate + networks: + - service-lens environment: - OPENFGA_DATASTORE_ENGINE=postgres - - OPENFGA_DATASTORE_URI=postgres://root@crdb:26257/defaultdb?sslmode=disable + - OPENFGA_DATASTORE_URI=postgres://postgres:password@postgres:5432/postgres?sslmode=disable openfga: depends_on: @@ -31,9 +37,11 @@ services: condition: service_completed_successfully image: openfga/openfga:latest container_name: openfga + networks: + - service-lens environment: - OPENFGA_DATASTORE_ENGINE=postgres - - OPENFGA_DATASTORE_URI=postgres://root@crdb:26257/defaultdb?sslmode=disable + - OPENFGA_DATASTORE_URI=postgres://postgres:password@postgres:5432/postgres?sslmode=disable - OPENFGA_LOG_FORMAT=json command: run ports: @@ -41,5 +49,9 @@ services: - "8081:8081" - "3000:3000" +networks: + service-lens: + + volumes: - crdb: {} + pg: {} diff --git a/internal/cfg/config.go b/internal/cfg/config.go index 0d08013..e338d20 100644 --- a/internal/cfg/config.go +++ b/internal/cfg/config.go @@ -8,14 +8,14 @@ import ( type Flags struct { Environment string `envconfig:"SERVICE_LENS_ENV" default:"production"` Addr string `envconfig:"SERVICE_LENS_ADDR" default:":8084"` - DatabaseURI string `envconfig:"SERVICE_LENS_DATABASE_URI" default:"postgres://root@host.docker.internal:26257/defaultdb?sslmode=disable"` + DatabaseURI string `envconfig:"SERVICE_LENS_DATABASE_URI" default:""` DatabaseTablePrefix string `envconfig:"SERVICE_LENS_DATABASE_TABLE_PREFIX" default:"service_lens_"` - FGAApiUrl string `envconfig:"SERVICE_LENS_FGA_API_URL" default:"http://host.docker.internal:8080"` + FGAApiUrl string `envconfig:"SERVICE_LENS_FGA_API_URL" default:""` FGAStoreID string `envconfig:"SERVICE_LENS_FGA_STORE_ID" default:""` FGAAuthorizationModelID string `envconfig:"SERVICE_LENS_FGA_AUTHORIZATION_MODEL_ID" default:""` OIDCIssuer string `envconfig:"SERVICE_LENS_OIDC_ISSUER" default:""` OIDCAudience string `envconfig:"SERVICE_LENS_OIDC_AUDIENCE" default:""` - GitHubCallbackURL string `envconfig:"SERVICE_LENS_GITHUB_CALLBACK_URL" default:"http://localhost:8084/auth/github/callback"` + GitHubCallbackURL string `envconfig:"SERVICE_LENS_GITHUB_CALLBACK_URL" default:""` GitHubClientID string `envconfig:"SERVICE_LENS_GITHUB_CLIENT_ID" default:""` GitHubClientSecret string `envconfig:"SERVICE_LENS_GITHUB_CLIENT_SECRET" default:""` }