Skip to content

Commit

Permalink
chore: change to postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored Sep 3, 2024
1 parent 8bce601 commit f998465
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
40 changes: 26 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,57 @@
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:
migrate:
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:
- "8080:8080"
- "8081:8081"
- "3000:3000"

networks:
service-lens:


volumes:
crdb: {}
pg: {}
6 changes: 3 additions & 3 deletions internal/cfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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://[email protected]: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:""`
}
Expand Down

0 comments on commit f998465

Please sign in to comment.