temp commit

This commit is contained in:
Rohan Sircar 2021-04-15 20:18:17 +05:30
parent b6070c9fe6
commit c7860c6611
5 changed files with 59 additions and 11 deletions

View File

@ -1,18 +1,61 @@
name: Build name: PostgreSQL service example
on: push on: push
jobs: jobs:
# Label of the container job
build: build:
# Containers must run in Linux based operating systems
runs-on: ubuntu-latest runs-on: ubuntu-latest
# Docker Hub image that `container-job` executes in
container: node:12-buster
env:
# The hostname used to communicate with the PostgreSQL service container
CODEGEN_DB_HOST: postgres
# The default PostgreSQL port
CODEGEN_DB_PORT: 5435
CODEGEN_DB_USER: codegenuser
CODEGEN_DB_PASSWOD: postgres
CODEGEN_DB_NAME: codegendb
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: codegenuser
POSTGRES_DB: codegendb
port:
- 5435:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps: steps:
- name: Checkout # Downloads a copy of the code in your repository before running CI tests
- name: Check out repository code
uses: actions/checkout@v2 uses: actions/checkout@v2
# - name: Coursier cache # - name: Coursier cache
# uses: coursier/cache-action@v6 # uses: coursier/cache-action@v6
- name: Setup - name: Setup
uses: olafurpg/setup-scala@v10 uses: olafurpg/setup-scala@v10
with: with:
java-version: adopt@1.11 java-version: adopt@1.11
# - run: sbt compile # - name: Connect to PostgreSQL
# - run: sbt test # # Runs a script that creates a PostgreSQL client, populates
- run: ./build.sh # # the client with data, and retrieves data
# run: node client.js
- name: Migrate
run: csbt flyway/flywayMigrate
- name: Run Tests
run: csbt test
- name: Package
run: csbt docker:stage
# Environment variable used by the `client.js` script to create a new PostgreSQL client.

View File

@ -45,11 +45,8 @@ lazy val root = (project in file("."))
name := "http4s-demo", name := "http4s-demo",
version := "0.0.1-SNAPSHOT", version := "0.0.1-SNAPSHOT",
version in Docker := "0.0.1", version in Docker := "0.0.1",
dockerExposedPorts ++= Seq(9000, 9001),
dockerBaseImage := "openjdk:11-slim", dockerBaseImage := "openjdk:11-slim",
dockerUsername := Some("rohansircar"), dockerUsername := Some("rohansircar"),
// dockerVe
// dockerRepository := ""
scalacOptions ++= Seq( scalacOptions ++= Seq(
"-encoding", "-encoding",
"UTF-8", "UTF-8",

View File

@ -16,7 +16,8 @@ echo "Container id is $cid"
sleep 5s sleep 5s
# ./wait-for-it.sh localhost:5434 -s -t 300 -- echo "db started" # ./wait-for-it.sh localhost:5434 -s -t 300 -- echo "db started"
sbtn flyway/flywayMigrate sbtn flyway/flywayMigrate
sbtn docker:publishLocal # needs docker login
sbtn docker:publish
sbtn shutdown sbtn shutdown
docker stop $cid docker stop $cid

View File

@ -3,4 +3,4 @@ docker run \
-e POSTGRES_USER=test_user \ -e POSTGRES_USER=test_user \
-e POSTGRES_PASSWORD=password \ -e POSTGRES_PASSWORD=password \
-p 5433:5432 \ -p 5433:5432 \
postgres:12 -d postgres:12

View File

@ -2,7 +2,14 @@
myapp = { myapp = {
database = { database = {
driver = org.postgresql.Driver driver = org.postgresql.Driver
url = "jdbc:postgresql://localhost:5432/test_db" # url = "jdbc:postgresql://localhost:5432/test_db"
dbHost = localhost
dbHost = ${?APP_DB_HOST}
dbPort = 5432
dbPort = ${?APP_DB_PORT}
dbName = test_db
dbName = ${?APP_DB_NAME}
url = "jdbc:postgresql://"${myapp.database.dbHost}":"${myapp.database.dbPort}"/"${myapp.database.dbName}
user = "test_user" user = "test_user"
password = "password" password = "password"