Skip to content

Commit

Permalink
OPHYK-214 Add varda-rekisterointi to start-local-env script
Browse files Browse the repository at this point in the history
  • Loading branch information
rce committed Dec 23, 2024
1 parent 6dfb235 commit db81340
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 142 deletions.
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,32 @@ services:
ports:
- 5433:5432
command: ["postgres", "-c", "log_statement=all"]

varda-rekisterointi-db:
container_name: varda-rekisterointi-db
image: postgres:15.7
environment:
- POSTGRES_USER=varda-rekisterointi
- POSTGRES_PASSWORD=varda-rekisterointi
- POSTGRES_DB=varda-rekisterointi
ports:
- "5438:5432"
command: ["postgres", "-c", "log_statement=all"]
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
varda-rekisterointi-test-db:
container_name: varda-rekisterointi-test-db
image: postgres:15.7
environment:
- POSTGRES_USER=varda-rekisterointi
- POSTGRES_PASSWORD=varda-rekisterointi
- POSTGRES_DB=varda-rekisterointi
ports:
- "5439:5432"
command: ["postgres", "-c", "log_statement=all"]

volumes:
database-data:
10 changes: 10 additions & 0 deletions scripts/lib/common-functions.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
export repo="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
readonly node_version=$( cat "$repo/.nvmrc" )

function wait_for_container_to_be_healthy {
require_docker
local -r container_name="$1"

info "Waiting for docker container $container_name to be healthy"
until [ "$(docker inspect -f {{.State.Health.Status}} "$container_name" 2>/dev/null || echo "not-running")" == "healthy" ]; do
sleep 2
done
}

function require_docker {
require_command docker
docker ps >/dev/null 2>&1 || fatal "Running 'docker ps' failed. Is docker daemon running? Aborting."
Expand Down
40 changes: 1 addition & 39 deletions scripts/run-organisaatio-service.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
readonly repo="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)"
source "$( dirname "${BASH_SOURCE[0]}" )/lib/common-functions.sh"

function main {
wait_for_local_db_to_be_healthy
Expand All @@ -18,42 +18,4 @@ function wait_for_local_db_to_be_healthy {
wait_for_container_to_be_healthy oph-organisaatio-db
}

function wait_for_container_to_be_healthy {
require_docker
local -r container_name="$1"

info "Waiting for docker container $container_name to be healthy"
until [ "$(docker inspect -f {{.State.Health.Status}} "$container_name" 2>/dev/null || echo "not-running")" == "healthy" ]; do
sleep 2
done
}

function require_docker {
require_command docker
docker ps >/dev/null 2>&1 || fatal "Running 'docker ps' failed. Is docker daemon running? Aborting."
}

function require_command {
if ! command -v "$1" >/dev/null; then
fatal "I require $1 but it's not installed. Aborting."
fi
}

function info {
log "INFO" "$1"
}

function fatal {
log "ERROR" "$1"
exit 1
}

function log {
local -r level="$1"
local -r message="$2"
local -r timestamp=$(date +"%Y-%m-%d %H:%M:%S")

echo >&2 -e "${timestamp} ${level} ${message}"
}

main "$@"
17 changes: 17 additions & 0 deletions scripts/run-varda-rekisterointi-ui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
source "$( dirname "${BASH_SOURCE[0]}" )/lib/common-functions.sh"

function main {
echo "${repo}"
export NVM_DIR="${NVM_DIR:-$HOME/.cache/nvm}"
source "${repo}/scripts/lib/nvm.sh"

nvm use 20 || nvm install -b 20 && nvm use 20

cd "${repo}/varda-rekisterointi"
npm_ci_if_needed
npm start
}

main "$@"
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
source "$( dirname "${BASH_SOURCE[0]}" )/lib/common-functions.sh"

function main {
select_java_version "21"
Expand All @@ -11,6 +12,7 @@ function main {
SERVICE_USERNAME="dummy"
SERVICE_PASSWORD="dummy"

cd "${repo}/varda-rekisterointi"
mvn spring-boot:run \
-Dspring-boot.run.profiles=dev \
-Dspring-boot.run.jvmArguments="
Expand All @@ -32,42 +34,4 @@ function wait_for_local_db_to_be_healthy {
wait_for_container_to_be_healthy varda-rekisterointi-db
}

function wait_for_container_to_be_healthy {
require_docker
local -r container_name="$1"

info "Waiting for docker container $container_name to be healthy"
until [ "$(docker inspect -f {{.State.Health.Status}} "$container_name" 2>/dev/null || echo "not-running")" == "healthy" ]; do
sleep 2
done
}

function require_docker {
require_command docker
docker ps >/dev/null 2>&1 || fatal "Running 'docker ps' failed. Is docker daemon running? Aborting."
}

function require_command {
if ! command -v "$1" >/dev/null; then
fatal "I require $1 but it's not installed. Aborting."
fi
}

function info {
log "INFO" "$1"
}

function fatal {
log "ERROR" "$1"
exit 1
}

function log {
local -r level="$1"
local -r message="$2"
local -r timestamp=$(date +"%Y-%m-%d %H:%M:%S")

echo >&2 -e "${timestamp} ${level} ${message}"
}

main
main "$@"
9 changes: 9 additions & 0 deletions start-local-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ function main {
tmux splitw -h
tmux send-keys "$repo/scripts/run-organisaatio-service.sh" C-m

tmux select-pane -t 1
tmux splitw -v
tmux send-keys "$repo/scripts/run-varda-rekisterointi.sh" C-m

tmux select-pane -t 4
tmux splitw -v
tmux send-keys "$repo/scripts/run-varda-rekisterointi-ui.sh" C-m

open "http://localhost:3003/organisaatio-service/organisaatiot"
open "http://localhost:3000/varda-rekisterointi"

tmux attach-session -t "$session"
}
Expand Down
28 changes: 0 additions & 28 deletions varda-rekisterointi/docker-compose.yml

This file was deleted.

2 changes: 1 addition & 1 deletion varda-rekisterointi/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spring:
main:
banner-mode: "off"
datasource:
url: jdbc:postgresql://localhost:${db.port:5432}/varda-rekisterointi
url: jdbc:postgresql://localhost:5438/varda-rekisterointi
username: varda-rekisterointi
password: varda-rekisterointi
flyway:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
spring:
datasource:
url: jdbc:postgresql://localhost:5433/varda-rekisterointi
url: jdbc:postgresql://localhost:5439/varda-rekisterointi
username: varda-rekisterointi
password: varda-rekisterointi
db-scheduler:
Expand Down
34 changes: 0 additions & 34 deletions varda-rekisterointi/start-local-env.sh

This file was deleted.

0 comments on commit db81340

Please sign in to comment.