Add app prefix to env variables

This commit is contained in:
Rohan Sircar 2021-05-05 12:00:21 +05:30
parent 4262e045f5
commit ddefc489e7
3 changed files with 38 additions and 30 deletions

View File

@ -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

View File

@ -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,

View File

@ -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