diff --git a/.env.example b/.env.example index f656e0f..13b375c 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,2 @@ TOKEN= +DB_HOST=db diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ab8e2ce..3053449 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,6 +14,7 @@ jobs: uses: SpicyPizza/create-envfile@v1 with: envkey_TOKEN: ${{ secrets.TOKEN }} + envkey_DB_HOST: db - uses: alex-ac/github-action-ssh-docker-compose@master name: Docker-Compose Remote Deployment with: diff --git a/src/main/kotlin/io/github/wulkanowy/schools/DatabaseFactory.kt b/src/main/kotlin/io/github/wulkanowy/schools/DatabaseFactory.kt index cb4332d..05267a1 100644 --- a/src/main/kotlin/io/github/wulkanowy/schools/DatabaseFactory.kt +++ b/src/main/kotlin/io/github/wulkanowy/schools/DatabaseFactory.kt @@ -9,8 +9,9 @@ import org.jetbrains.exposed.sql.transactions.transaction object DatabaseFactory { fun init() { + val host = System.getenv("DB_HOST") ?: "localhost" val database = Database.connect( - url = "jdbc:pgsql://localhost:5004/schools", + url = "jdbc:pgsql://$host:5004/schools", driver = "com.impossibl.postgres.jdbc.PGDriver", user = "postgres", password = "postgres",