Browse Source

temp commit

devel
Rohan Sircar 3 years ago
parent
commit
c7860c6611
  1. 53
      .github/workflows/build.yaml
  2. 3
      build.sbt
  3. 3
      build.sh
  4. 2
      scripts/db.sh
  5. 9
      src/main/resources/application.conf

53
.github/workflows/build.yaml

@ -1,18 +1,61 @@
name: Build
name: PostgreSQL service example
on: push
jobs:
# Label of the container job
build:
# Containers must run in Linux based operating systems
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:
- name: Checkout
# Downloads a copy of the code in your repository before running CI tests
- name: Check out repository code
uses: actions/checkout@v2
# - name: Coursier cache
# uses: coursier/cache-action@v6
- name: Setup
uses: olafurpg/setup-scala@v10
with:
java-version: adopt@1.11
# - run: sbt compile
# - run: sbt test
- run: ./build.sh
# - name: Connect to PostgreSQL
# # Runs a script that creates a PostgreSQL client, populates
# # 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.

3
build.sbt

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

3
build.sh

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

2
scripts/db.sh

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

9
src/main/resources/application.conf

@ -2,7 +2,14 @@
myapp = {
database = {
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"
password = "password"

Loading…
Cancel
Save