why is the docker-compose setup so brittle? ```docker supertokens: image: registry.supertokens...
d
why is the docker-compose setup so brittle?
Copy code
docker
  supertokens:
    image: registry.supertokens.io/supertokens/supertokens-postgresql
    depends_on:
      - supertokens_database
    ports:
      - 3567:3567
    environment:
      POSTGRESQL_CONNECTION_URI: "postgresql://supertokens_user:somePassword@supertokens_database:5432/supertokens"
      #POSTGRESQL_CONNECTION_URI: "postgresql://${SUPERTOKENS_USER}:${SUPERTOKENS_PASSWORD}@database:5432/${SUPERTOKENS_DB}?schema=public"
    networks:
      - supertokens_network
    restart: unless-stopped
    healthcheck:
      test: >
        bash -c 'exec 3<>/dev/tcp/127.0.0.1/3567 && echo -e "GET /hello HTTP/1.1\r\nhost: 127.0.0.1:3567\r\nConnection: close\r\n\r\n" >&3 && cat <&3 | grep "Hello"'
      interval: 10s
      timeout: 5s
      retries: 5

  supertokens_database:
    image: 'postgres:latest'
    restart: always
    environment:
      POSTGRES_USER: supertokens_user
      POSTGRES_PASSWORD: somePassword
      POSTGRES_DB: supertokens
    ports:
      - 5432:5432
    networks:
      - supertokens_network
    volumes:
      - ./volumes/supertokens:/var/lib/postgresql/data
      #- ./postgres:/var/lib/postgresql/data
    healthcheck:
      test: ['CMD', 'pg_isready -U supertokens_user']
      interval: 5s
      timeout: 5s
      retries: 5
r
can you remove this part:
Copy code
volumes:
      -
Thats not mentioned in our docs.
d
rp: removed it but still getting that 500 status response
still throws that connection pool error it seems
and presumably it doesn't matter what port I run
supertokens_database
on right? (e.g. 5433 instead of 5432)
r
doesn't matter as long as you have set the same port in the
POSTGRESQL_CONNECTION_URI
im not sure why this isn't working for you. Maybe check if the postgres db starts first
d
ok cool, so thats not the problem then
r
you may need to allow users to connect on that port
in postgres
i think user's in postgres are granted access based on host and port
so that may be the issue?
d
Copy code
2023-01-27 20:17:41 .2023-01-27 09:17:41.771 UTC [49] LOG:  aborting any active transactions
2023-01-27 20:17:41 2023-01-27 09:17:41.773 UTC [49] LOG:  background worker "logical replication launcher" (PID 55) exited with exit code 1
2023-01-27 20:17:41 2023-01-27 09:17:41.775 UTC [50] LOG:  shutting down
2023-01-27 20:17:41 2023-01-27 09:17:41.776 UTC [50] LOG:  checkpoint starting: shutdown immediate
2023-01-27 20:17:41 2023-01-27 09:17:41.809 UTC [50] LOG:  checkpoint complete: wrote 918 buffers (5.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.012 s, sync=0.019 s, total=0.034 s; sync files=250, longest=0.004 s, average=0.001 s; distance=4217 kB, estimate=4217 kB
2023-01-27 20:17:41 2023-01-27 09:17:41.820 UTC [49] LOG:  database system is shut down
2023-01-27 20:17:41  done
2023-01-27 20:17:41 server stopped
2023-01-27 20:17:41 
2023-01-27 20:17:41 PostgreSQL init process complete; ready for start up.
2023-01-27 20:17:41 
2023-01-27 20:17:41 initdb: warning: enabling "trust" authentication for local connections
2023-01-27 20:17:41 initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
2023-01-27 20:17:41 2023-01-27 09:17:41.888 UTC [1] LOG:  starting PostgreSQL 15.1 (Debian 15.1-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2023-01-27 20:17:41 2023-01-27 09:17:41.888 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-01-27 20:17:41 2023-01-27 09:17:41.888 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-01-27 20:17:41 2023-01-27 09:17:41.890 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-01-27 20:17:41 2023-01-27 09:17:41.894 UTC [65] LOG:  database system was shut down at 2023-01-27 09:17:41 UTC
2023-01-27 20:17:41 2023-01-27 09:17:41.898 UTC [1] LOG:  database system is ready to accept connections
r
hmm. this seems fine i guess
d
Copy code
2023-01-27 20:22:42 27 Jan 2023 09:22:42:607 +0000 | INFO | pid: d32baf58-80d7-4fd6-8aec-db073b75db64 | [main] thread | io.supertokens.storage.postgresql.ConnectionPool.initPool(ConnectionPool.java:154) | Trying again in a few seconds for 55.0 mins...
2023-01-27 20:22:42 
2023-01-27 20:22:42 Trying again in a few seconds for 55.0 mins...
2023-01-27 20:22:52 27 Jan 2023 09:22:52:616 +0000 | ERROR | pid: d32baf58-80d7-4fd6-8aec-db073b75db64 | [main] thread | io.supertokens.storage.postgresql.HikariLoggingAppender.doAppend(HikariLoggingAppender.java:132) | SuperTokens - Exception during pool initialization.
2023-01-27 20:22:52 
2023-01-27 20:22:52 27 Jan 2023 09:22:52:617 +0000 | INFO | pid: d32baf58-80d7-4fd6-8aec-db073b75db64 | [main] thread | io.supertokens.storage.postgresql.ConnectionPool.initPool(ConnectionPool.java:154) | Trying again in a few seconds for 54.8 mins...
2023-01-27 20:22:52 
2023-01-27 20:22:52 Trying again in a few seconds for 54.8 mins...
no cause is given though
r
this just means that the db is not started, or not reachable.
oh! you have not added the network config
Copy code
networks:
  supertokens_network:
    driver: bridge
here is a sample docker compose file which works
Copy code
version: '3'
  
services:
  db:
    image: 'postgres:latest'
    environment:
      POSTGRES_USER: supertokens_user 
      POSTGRES_PASSWORD: somePassword 
      POSTGRES_DB: supertokens
    ports:
      - 5432:5432
    networks:
      - app_network
    restart: unless-stopped
    healthcheck:
      test: ['CMD', 'pg_isready -U supertokens_user']
      interval: 5s
      timeout: 5s
      retries: 5

  supertokens:
    image: registry.supertokens.io/supertokens/supertokens-postgresql:4.3
    depends_on:
      db:
        condition: service_healthy
    ports:
      - 3567:3567
    environment:
      POSTGRESQL_CONNECTION_URI: "postgresql://supertokens_user:somePassword@db:5432/supertokens"
    networks:
      - app_network
    restart: unless-stopped
    healthcheck:
      test: >
        bash -c 'exec 3<>/dev/tcp/127.0.0.1/3567 && echo -e "GET /hello HTTP/1.1\r\nhost: 127.0.0.1:3567\r\nConnection: close\r\n\r\n" >&3 && cat <&3 | grep "Hello"'
      interval: 10s
      timeout: 5s
      retries: 5

networks:
  app_network:
    driver: bridge