How to use Environment Variables and application.conf files in Scala?

I am unsure of how to get environment variables from my dev.env and prod.env into my application.conf (or reference them from the conf file).

I want to deploy my app to heroku and connect it to heroku's database. In the future, I'll want to deploy to AWS in docker container.

Can some please explain how environment variables work in Scala and explain how to refernce the environement variables from application.conf.

I already have a configLoader.

Below is a picture of my file structure and I have also copied code below:

enter image description here

application.conf file below:

    akka {
      loggers = ["akka.event.slf4j.Slf4jLogger"]
      loglevel = DEBUG
    }

    server-config {
      host = "0.0.0.0"
      port = 8080
      base-url = ${?BASE_URL}
    }

    db-config {
      url = {?JDBC_DATABASE_URL}
      username = "su"
      password = "password"
      pool-size = 10
      driver="org.h2.Driver"
    }

dev.env below:

ENV=dev

BASE_URL=http://localhost:8080

JDBC_DATABASE_URL=jdbc:postgresql://localhost:5400/bookswapdb

prd.env below:

ENV=${_ENVIRONMENT}

BASE_URL=https://git.heroku.com/appone2021.git

JDBC_DATABASE_URL=${URL_WITH_CREDS_REDACTED}



from Recent Questions - Stack Overflow https://ift.tt/3qiGwam
https://ift.tt/2N0v5Wq

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation