From ddefc489e7a4dd709e774364e7b87f150af05af9 Mon Sep 17 00:00:00 2001 From: Rohan Sircar Date: Wed, 5 May 2021 12:00:21 +0530 Subject: [PATCH] Add app prefix to env variables --- .github/workflows/ci.yaml | 36 ++++++++++++++--------------- build.sbt | 22 ++++++++++++------ src/main/resources/application.conf | 10 ++++---- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 60246f4..bde27b8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,11 +32,11 @@ jobs: name: Build and Test runs-on: ubuntu-latest env: - CODEGEN_DB_HOST: localhost - CODEGEN_DB_PORT: 5432 - CODEGEN_DB_USER: codegenuser - CODEGEN_DB_PASSWORD: postgres - CODEGEN_DB_NAME: codegendb + HTTP4S_DEMO_CODEGEN_DB_HOST: localhost + HTTP4S_DEMO_CODEGEN_DB_PORT: 5432 + HTTP4S_DEMO_CODEGEN_DB_USER: codegenuser + HTTP4S_DEMO_CODEGEN_DB_PASSWORD: postgres + HTTP4S_DEMO_CODEGEN_DB_NAME: codegendb services: postgres: image: postgres:12-alpine @@ -81,12 +81,12 @@ jobs: if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) runs-on: ubuntu-latest env: - CODEGEN_DB_HOST: localhost - CODEGEN_DB_PORT: 5432 - CODEGEN_DB_USER: codegenuser - CODEGEN_DB_PASSWORD: postgres - CODEGEN_DB_NAME: codegendb - DOCKER_JAVA_IMAGE: azul/zulu-openjdk-alpine:11-jre-headless + HTTP4S_DEMO_CODEGEN_DB_HOST: localhost + HTTP4S_DEMO_CODEGEN_DB_PORT: 5432 + HTTP4S_DEMO_CODEGEN_DB_USER: codegenuser + HTTP4S_DEMO_CODEGEN_DB_PASSWORD: postgres + HTTP4S_DEMO_CODEGEN_DB_NAME: codegendb + HTTP4S_DEMO_DOCKER_JAVA_IMAGE: azul/zulu-openjdk-alpine:11-jre-headless services: postgres: image: postgres:12-alpine @@ -135,13 +135,13 @@ jobs: if: github.event_name != 'pull_request' && github.ref == 'refs/heads/devel' runs-on: ubuntu-latest env: - CODEGEN_DB_HOST: localhost - CODEGEN_DB_PORT: 5432 - CODEGEN_DB_USER: codegenuser - CODEGEN_DB_PASSWORD: postgres - CODEGEN_DB_NAME: codegendb - DOCKER_JAVA_IMAGE: azul/zulu-openjdk-alpine:11-jre-headless - DOCKER_PUBLISH_TAG: devel + HTTP4S_DEMO_CODEGEN_DB_HOST: localhost + HTTP4S_DEMO_CODEGEN_DB_PORT: 5432 + HTTP4S_DEMO_CODEGEN_DB_USER: codegenuser + HTTP4S_DEMO_CODEGEN_DB_PASSWORD: postgres + HTTP4S_DEMO_CODEGEN_DB_NAME: codegendb + HTTP4S_DEMO_DOCKER_JAVA_IMAGE: azul/zulu-openjdk-alpine:11-jre-headless + HTTP4S_DEMO_DOCKER_PUBLISH_TAG: devel services: postgres: image: postgres:12-alpine diff --git a/build.sbt b/build.sbt index 577486b..6db9403 100644 --- a/build.sbt +++ b/build.sbt @@ -17,19 +17,27 @@ import com.github.tototoshi.sbt.slick.CodegenPlugin.autoImport.{ import slick.codegen.SourceCodeGenerator import slick.{model => m} -lazy val codegenDbHost = sys.env.getOrElse("CODEGEN_DB_HOST", "localhost") -lazy val codegenDbPort = sys.env.getOrElse("CODEGEN_DB_PORT", "5432") -lazy val codegenDbName = sys.env.getOrElse("CODEGEN_DB_NAME", "test_db") +lazy val codegenDbHost = + sys.env.getOrElse("HTTP4S_DEMO_CODEGEN_DB_HOST", "localhost") +lazy val codegenDbPort = + sys.env.getOrElse("HTTP4S_DEMO_CODEGEN_DB_PORT", "5432") +lazy val codegenDbName = + sys.env.getOrElse("HTTP4S_DEMO_CODEGEN_DB_NAME", "test_db") lazy val databaseUrl = s"jdbc:postgresql://$codegenDbHost:$codegenDbPort/$codegenDbName" -lazy val databaseUser = sys.env.getOrElse("CODEGEN_DB_USER", "test_user") -lazy val databasePassword = sys.env.getOrElse("CODEGEN_DB_PASSWORD", "password") +lazy val databaseUser = + sys.env.getOrElse("HTTP4S_DEMO_CODEGEN_DB_USER", "test_user") +lazy val databasePassword = + sys.env.getOrElse("HTTP4S_DEMO_CODEGEN_DB_PASSWORD", "password") // alpine java docker image for smaller size - "azul/zulu-openjdk-alpine:11-jre-headless" lazy val dockerJavaImage = - sys.env.getOrElse("DOCKER_JAVA_IMAGE", "openjdk:11-jre-slim-buster") + sys.env.getOrElse( + "HTTP4S_DEMO_DOCKER_JAVA_IMAGE", + "openjdk:11-jre-slim-buster" + ) lazy val flyway = (project in file("modules/flyway")) .enablePlugins(FlywayPlugin) @@ -65,7 +73,7 @@ lazy val root = (project in file(".")) organization := "wow.doge", name := "http4s-demo", version in Docker := sys.env - .get("DOCKER_PUBLISH_TAG") + .get("HTTP4S_DEMO_DOCKER_PUBLISH_TAG") .map(s => if (s.startsWith("v")) s.tail else s) .getOrElse(version.value), dockerBaseImage := dockerJavaImage, diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 4629e3d..b22acbe 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -3,16 +3,16 @@ myapp = { database = { driver = org.postgresql.Driver dbHost = localhost - dbHost = ${?APP_DB_HOST} + dbHost = ${?HTTP4S_DEMO_DB_HOST} dbPort = 5432 - dbPort = ${?APP_DB_PORT} + dbPort = ${?HTTP4S_DEMO_DB_PORT} dbName = test_db - dbName = ${?APP_DB_NAME} + dbName = ${?HTTP4S_DEMO_DB_NAME} url = "jdbc:postgresql://"${myapp.database.dbHost}":"${myapp.database.dbPort}"/"${myapp.database.dbName} user = "test_user" - user = ${?APP_DB_USER} + user = ${?HTTP4S_DEMO_DB_USER} password = "password" - password = ${?APP_DB_PASSWORD} + password = ${?HTTP4S_DEMO_DB_PASSWORD} numThreads = 16 queueSize = 1000 maxConnections = 16