i am connecting to remote database using docker an...
# talk-kratos
e
i am connecting to remote database using docker and I use
docker-compose up -d
to run the service and i am able to sign up new accounts and also able to login, however when i restart the container with
docker-compose down
and then 'docker-compose up -d', it doesn't recognise the old accounts added as if they were deleted. I am using default identity schema here is my docker compose file
Copy code
version: "3.9"
services:
  kratos-migrate-oiconomos:
    image: oryd/kratos:v0.10.1
    hostname: kratos-migrate-oiconomos
    container_name: kratos-migrate-oiconomos
    environment:
      - DNS=mysql://${DB_USER}:${DB_PASSWORD}@aws.connect.psdb.cloud/billboard?tls=false&max_conns=20&max_idle_conns=4
    volumes:
      - ./kratos:/etc/config/kratos
    command: -c /etc/config/kratos/kratos.yml migrate sql -e --yes
    restart: on-failure

  kratos-oiconomos:
    image: oryd/kratos:v0.10.1
    hostname: kratos-oiconomos
    container_name: kratos-oiconomos
    depends_on:
      - kratos-migrate-oiconomos
    environment:
      - DNS=mysql://${DB_USER}:${DB_PASSWORD}@aws.connect.psdb.cloud/billboard?tls=false&max_conns=20&max_idle_conns=4
    ports:
      - ${KRATOS_EXPOSE_PORT}:4433
      - ${KRATOS_ADMIN_EXPOSE_PORT}:4434
    volumes:
      - ./kratos:/etc/config/kratos
    command: serve -c /etc/config/kratos/kratos.yml --dev --watch-courier
    restart: unless-stopped

  kratos-selfservice-ui-node-oiconomos:
    image: oryd/kratos-selfservice-ui-node:v0.10.1
    hostname: kratos-selfservice-ui-node-oiconomos
    container_name: kratos-selfservice-ui-node-oiconomos
    depends_on:
      - kratos-migrate-oiconomos
    environment:
      - KRATOS_PUBLIC_URL=<http://kratos-oiconomos:4433/|http://kratos-oiconomos:4433/> 
      - KRATOS_BROWSER_URL=<http://127.0.0.1:${KRATOS_EXPOSE_PORT}/|http://127.0.0.1:${KRATOS_EXPOSE_PORT}/>
    ports:
      - ${KRATOS_UI_EXPOSE_PORT}:3000
    restart: on-failure

volumes:
  kratos:

networks:
  default:
    name: kratos-oiconomos-net
here is my kratos.yml file
Copy code
version: v0.7.1-alpha.1

dsn: memory

serve:
  public:
    base_url: <http://127.0.0.1:3433/|http://127.0.0.1:3433/>
    cors:
      enabled: true
  admin:
    base_url: <http://kratos-oiconomos:4434/|http://kratos-oiconomos:4434/>

selfservice:
  default_browser_return_url: <http://127.0.0.1:3000/|http://127.0.0.1:3000/>
  allowed_return_urls:
    - <http://127.0.0.1:3000|http://127.0.0.1:3000>

  methods:
    password:
      enabled: true

  flows:
    error:
      ui_url: <http://127.0.0.1:3000/error|http://127.0.0.1:3000/error>

    settings:
      ui_url: <http://127.0.0.1:3000/settings|http://127.0.0.1:3000/settings>
      privileged_session_max_age: 15m

    recovery:
      enabled: true
      ui_url: <http://127.0.0.1:3000/recovery|http://127.0.0.1:3000/recovery>

    verification:
      enabled: true
      ui_url: <http://127.0.0.1:3000/verification|http://127.0.0.1:3000/verification>
      after:
        default_browser_return_url: <http://127.0.0.1:3000/|http://127.0.0.1:3000/>

    logout:
      after:
        default_browser_return_url: <http://127.0.0.1:3000/login|http://127.0.0.1:3000/login>

    login:
      ui_url: <http://127.0.0.1:3000/login|http://127.0.0.1:3000/login>
      lifespan: 10m

    registration:
      lifespan: 10m
      ui_url: <http://127.0.0.1:3000/registration|http://127.0.0.1:3000/registration>
      after:
        password:
          hooks:
            - hook: session

log:
  level: debug
  format: text
  leak_sensitive_values: true

secrets:
  cookie:
    - PLEASE-CHANGE-ME-I-AM-VERY-INSECURE
  cipher:
    - 32-LONG-SECRET-NOT-SECURE-AT-ALL

ciphers:
  algorithm: xchacha20-poly1305

hashers:
  algorithm: bcrypt
  bcrypt:
    cost: 8

identity:
  default_schema_id: default
  schemas:
    - id: default
      url: file:///etc/config/kratos/identity.schema.json

courier:
  smtp:
    connection_uri: <smtps://test:test@mailslurper:1025/?skip_ssl_verify=true|smtps://test:test@mailslurper:1025/?skip_ssl_verify=true>
s
I'd recommend to debug on the database side, i.e. check whether the user actually shows up there
and just to make sure it does not use the in-memory db, set the
dsn
key in the config to e.g.
placeholder
e
okay let me try this
hi you were right... the dns was set to memory
however in configuration docs it is saying i can set dns as environment variables, and i am. doing so in docker you can see above. But the dsn value is not taken by environment.. i even checked in the container and dns value is set to environment still it is taking from the kratos.yml file
i have different environment for different things which i want to manage through docker but this is causing the issue
never mind never mind.. i had a typo in my docker-compose i spelled dsn as DNS.. and as i can see i was doing the same while messaging here as well 😂
s
haha ok that can happen easily 😂
e
thanks for your help! i should've gone through the config docs. Thank you for your time!
s
no worries