generated from ministryofjustice/hmpps-template-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fri 17/add schema doc generation (#28)
* Add build step for build of data dictionary [schemaspy] * Add orb import
- Loading branch information
1 parent
3b60e29
commit a8e3d78
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
version: 2.1 | ||
orbs: | ||
hmpps: ministryofjustice/hmpps@10 | ||
mem: circleci/[email protected] | ||
parameters: | ||
releases-slack-channel: | ||
type: string | ||
|
@@ -51,10 +52,53 @@ jobs: | |
path: build/test-results | ||
- store_artifacts: | ||
path: build/reports/tests | ||
|
||
publish_data: | ||
executor: | ||
name: hmpps/java | ||
tag: "21" | ||
docker: *db_docker_config | ||
steps: | ||
- checkout | ||
- mem/recall: | ||
env_var: APP_VERSION | ||
- run: | ||
name: Migrate the database | ||
command: | | ||
wget -qO- https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/10.15.2/flyway-commandline-10.15.2-linux-x64.tar.gz | \ | ||
tar xvz && sudo ln -s `pwd`/flyway-10.15.2/flyway /usr/local/bin | ||
flyway migrate -url="jdbc:postgresql://localhost:5433/$POSTGRES_DB" -user="postgres" -password="password" -locations="src/main/resources/db/migration" -postgresql.transactional.lock=false | ||
- setup_remote_docker | ||
- run: | ||
name: Build data dictionary | ||
command: | | ||
sudo apt update && sudo apt install graphviz | ||
script/build-data-dictionary.sh | ||
- run: | ||
name: Tag docker image | ||
command: | | ||
docker tag data-dictionary "quay.io/hmpps/${CIRCLE_PROJECT_REPONAME}:data-dictionary-${APP_VERSION}" | ||
- when: | ||
condition: | ||
or: | ||
- equal: [ main, << pipeline.git.branch >> ] | ||
- matches: | ||
pattern: "^hotfix/.+$" | ||
value: << pipeline.git.branch >> | ||
steps: | ||
- run: | ||
name: Publish docker image | ||
command: | | ||
docker login -u="${QUAYIO_USERNAME}" -p="${QUAYIO_PASSWORD}" quay.io | ||
docker push "quay.io/hmpps/${CIRCLE_PROJECT_REPONAME}:data-dictionary-${APP_VERSION}" | ||
workflows: | ||
version: 2 | ||
build-test-and-deploy: | ||
jobs: | ||
- publish_data: | ||
requires: | ||
- build_docker | ||
- validate: | ||
filters: | ||
tags: | ||
|
@@ -81,6 +125,7 @@ workflows: | |
requires: | ||
- validate | ||
- build_docker | ||
- publish_data | ||
- helm_lint | ||
helm_timeout: 5m | ||
# - request-preprod-approval: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM bitnami/nginx:1.27 | ||
|
||
WORKDIR /app | ||
COPY schema/ meta/schema/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh -e | ||
basedir=$(dirname "$0") | ||
jardir="$basedir/libs" | ||
schemadir="$basedir/schema" | ||
|
||
mkdir -p "$jardir" "$schemadir" | ||
|
||
wget https://github.com/schemaspy/schemaspy/releases/download/v6.1.0/schemaspy-6.1.0.jar -O "$jardir/schemaspy.jar" | ||
wget https://jdbc.postgresql.org/download/postgresql-42.2.19.jar -O "$jardir/postgresql.jar" | ||
|
||
java -jar "$jardir/schemaspy.jar" -t pgsql -dp "$jardir/postgresql.jar" \ | ||
-db "${POSTGRES_DB:-findandrefer}" -host "localhost" -port "5433" -u "postgres" -p "password" \ | ||
-nopages \ | ||
-o "$schemadir" | ||
|
||
docker build --pull --file="$basedir/Dockerfile.data-dictionary" --tag=data-dictionary "$basedir" |