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 name: Build and Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
CODEGEN_DB_HOST: localhost HTTP4S_DEMO_CODEGEN_DB_HOST: localhost
CODEGEN_DB_PORT: 5432 HTTP4S_DEMO_CODEGEN_DB_PORT: 5432
CODEGEN_DB_USER: codegenuser HTTP4S_DEMO_CODEGEN_DB_USER: codegenuser
CODEGEN_DB_PASSWORD: postgres HTTP4S_DEMO_CODEGEN_DB_PASSWORD: postgres
CODEGEN_DB_NAME: codegendb HTTP4S_DEMO_CODEGEN_DB_NAME: codegendb
services: services:
postgres: postgres:
image: postgres:12-alpine 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')) if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
CODEGEN_DB_HOST: localhost HTTP4S_DEMO_CODEGEN_DB_HOST: localhost
CODEGEN_DB_PORT: 5432 HTTP4S_DEMO_CODEGEN_DB_PORT: 5432
CODEGEN_DB_USER: codegenuser HTTP4S_DEMO_CODEGEN_DB_USER: codegenuser
CODEGEN_DB_PASSWORD: postgres HTTP4S_DEMO_CODEGEN_DB_PASSWORD: postgres
CODEGEN_DB_NAME: codegendb HTTP4S_DEMO_CODEGEN_DB_NAME: codegendb
DOCKER_JAVA_IMAGE: azul/zulu-openjdk-alpine:11-jre-headless HTTP4S_DEMO_DOCKER_JAVA_IMAGE: azul/zulu-openjdk-alpine:11-jre-headless
services: services:
postgres: postgres:
image: postgres:12-alpine image: postgres:12-alpine
@ -135,13 +135,13 @@ jobs:
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/devel' if: github.event_name != 'pull_request' && github.ref == 'refs/heads/devel'
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
CODEGEN_DB_HOST: localhost HTTP4S_DEMO_CODEGEN_DB_HOST: localhost
CODEGEN_DB_PORT: 5432 HTTP4S_DEMO_CODEGEN_DB_PORT: 5432
CODEGEN_DB_USER: codegenuser HTTP4S_DEMO_CODEGEN_DB_USER: codegenuser
CODEGEN_DB_PASSWORD: postgres HTTP4S_DEMO_CODEGEN_DB_PASSWORD: postgres
CODEGEN_DB_NAME: codegendb HTTP4S_DEMO_CODEGEN_DB_NAME: codegendb
DOCKER_JAVA_IMAGE: azul/zulu-openjdk-alpine:11-jre-headless HTTP4S_DEMO_DOCKER_JAVA_IMAGE: azul/zulu-openjdk-alpine:11-jre-headless
DOCKER_PUBLISH_TAG: devel HTTP4S_DEMO_DOCKER_PUBLISH_TAG: devel
services: services:
postgres: postgres:
image: postgres:12-alpine image: postgres:12-alpine

View File

@ -17,19 +17,27 @@ import com.github.tototoshi.sbt.slick.CodegenPlugin.autoImport.{
import slick.codegen.SourceCodeGenerator import slick.codegen.SourceCodeGenerator
import slick.{model => m} import slick.{model => m}
lazy val codegenDbHost = sys.env.getOrElse("CODEGEN_DB_HOST", "localhost") lazy val codegenDbHost =
lazy val codegenDbPort = sys.env.getOrElse("CODEGEN_DB_PORT", "5432") sys.env.getOrElse("HTTP4S_DEMO_CODEGEN_DB_HOST", "localhost")
lazy val codegenDbName = sys.env.getOrElse("CODEGEN_DB_NAME", "test_db") 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 = lazy val databaseUrl =
s"jdbc:postgresql://$codegenDbHost:$codegenDbPort/$codegenDbName" s"jdbc:postgresql://$codegenDbHost:$codegenDbPort/$codegenDbName"
lazy val databaseUser = sys.env.getOrElse("CODEGEN_DB_USER", "test_user") lazy val databaseUser =
lazy val databasePassword = sys.env.getOrElse("CODEGEN_DB_PASSWORD", "password") 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" // alpine java docker image for smaller size - "azul/zulu-openjdk-alpine:11-jre-headless"
lazy val dockerJavaImage = 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")) lazy val flyway = (project in file("modules/flyway"))
.enablePlugins(FlywayPlugin) .enablePlugins(FlywayPlugin)
@ -65,7 +73,7 @@ lazy val root = (project in file("."))
organization := "wow.doge", organization := "wow.doge",
name := "http4s-demo", name := "http4s-demo",
version in Docker := sys.env 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) .map(s => if (s.startsWith("v")) s.tail else s)
.getOrElse(version.value), .getOrElse(version.value),
dockerBaseImage := dockerJavaImage, dockerBaseImage := dockerJavaImage,

View File

@ -3,16 +3,16 @@ myapp = {
database = { database = {
driver = org.postgresql.Driver driver = org.postgresql.Driver
dbHost = localhost dbHost = localhost
dbHost = ${?APP_DB_HOST} dbHost = ${?HTTP4S_DEMO_DB_HOST}
dbPort = 5432 dbPort = 5432
dbPort = ${?APP_DB_PORT} dbPort = ${?HTTP4S_DEMO_DB_PORT}
dbName = test_db dbName = test_db
dbName = ${?APP_DB_NAME} dbName = ${?HTTP4S_DEMO_DB_NAME}
url = "jdbc:postgresql://"${myapp.database.dbHost}":"${myapp.database.dbPort}"/"${myapp.database.dbName} url = "jdbc:postgresql://"${myapp.database.dbHost}":"${myapp.database.dbPort}"/"${myapp.database.dbName}
user = "test_user" user = "test_user"
user = ${?APP_DB_USER} user = ${?HTTP4S_DEMO_DB_USER}
password = "password" password = "password"
password = ${?APP_DB_PASSWORD} password = ${?HTTP4S_DEMO_DB_PASSWORD}
numThreads = 16 numThreads = 16
queueSize = 1000 queueSize = 1000
maxConnections = 16 maxConnections = 16