From f071e890ad25156b5996b0a026507cab739efe52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Mon, 18 Sep 2023 21:47:34 +0200 Subject: [PATCH] Fix db host --- .env.example | 1 + .github/workflows/deploy.yml | 1 + src/main/kotlin/io/github/wulkanowy/schools/DatabaseFactory.kt | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) 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",