Skip to content

Commit

Permalink
CNDIT-1589: Liquibase migration to the NEDSS-DataReporting repository
Browse files Browse the repository at this point in the history
  • Loading branch information
alog-enquizit committed Jul 24, 2024
1 parent a97bd28 commit 0bd3ade
Show file tree
Hide file tree
Showing 78 changed files with 19,746 additions and 1 deletion.
32 changes: 31 additions & 1 deletion .github/workflows/Build-and-deploy-reporting-services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- master
- rel-**
# Uncomment the following line only to test the build deploy from private branches.
# - CNDIT-*
- CNDIT-*
paths-ignore:
- "docker-compose.yml"
- "**.md"
Expand Down Expand Up @@ -186,3 +186,33 @@ jobs:
GIT_USER_NAME: ${{secrets.GIT_USER_NAME}}
HELM_TOKEN: ${{secrets.HELM_TOKEN}}

# liquibase-microservice
call-build-liquibase-microservice-container-workflow:
name: Build Liquibase Service Container
uses: CDCgov/NEDSS-Workflows/.github/workflows/Build-gradle-microservice-container.yaml@main
with:
microservice_name: liquibase-service
dockerfile_relative_path: -f ./liquibase-service/Dockerfile .
environment_classifier: SNAPSHOT
java_version: "17"
secrets:
CDC_NBS_SANDBOX_SHARED_SERVICES_ACCOUNTID: ${{secrets.CDC_NBS_SANDBOX_SHARED_SERVICES_ACCOUNTID}}
ECR_REPO_BASE_NAME: ${{secrets.ECR_NBS_REPO_BASE_NAME}}
GIT_USER_EMAIL: ${{secrets.GIT_USER_EMAIL}}
GIT_USER_NAME: ${{secrets.GIT_USER_NAME}}
HELM_TOKEN: ${{secrets.HELM_TOKEN}}

# Helm Update Liquibase service
call-update-helm-for-liquibase-microservice:
needs: call-build-liquibase-microservice-container-workflow
uses: CDCgov/NEDSS-Workflows/.github/workflows/Update-helm-charts.yaml@main
with:
microservice_name: liquibase-service
values_file_with_path: charts/liquibase/values-dts1.yaml
new_image_tag: ${{ needs.call-build-liquibase-microservice-container-workflow.outputs.output_image_tag }}
secrets:
GIT_USER_EMAIL: ${{secrets.GIT_USER_EMAIL}}
GIT_USER_NAME: ${{secrets.GIT_USER_NAME}}
HELM_TOKEN: ${{secrets.HELM_TOKEN}}


4 changes: 4 additions & 0 deletions liquibase-service/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.gradle
.idea
build
*.iml
43 changes: 43 additions & 0 deletions liquibase-service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
.idea/
.gradle/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

## Logs ##
logs/
*.log
25 changes: 25 additions & 0 deletions liquibase-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM liquibase/liquibase:latest-alpine

USER root

RUN apk add --no-cache wget unzip

RUN wget "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -O "awscliv2.zip" && \
unzip awscliv2.zip && rm -rf awscliv2.zip && \
./aws/install


#Copy sources
COPY liquibase-service/src/main/resources/db/changelog /liquibase/changelog
COPY liquibase-service/src/main/resources/db/master /liquibase/changelog
COPY liquibase-service/src/main/resources/db/odse /liquibase/changelog
COPY liquibase-service/src/main/resources/db/rdb /liquibase/changelog

#Set the Working Directory
WORKDIR /liquibase/changelog

USER liquibase

CMD ["sh", "-c", "tail -f /dev/null"]


110 changes: 110 additions & 0 deletions liquibase-service/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}

plugins {
id 'java'
id 'org.springframework.boot' version '3.2.4'
id 'io.spring.dependency-management' version '1.1.4'
id 'org.liquibase.gradle' version '2.2.2'
id 'org.sonarqube' version '4.2.1.3168'
}

//apply plugin: 'org.owasp.dependencycheck'

group = 'gov.cdc.eltdatapipeline'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = JavaVersion.VERSION_17
}

ext.isReleaseVersion = !version.endsWith("SNAPSHOT")

tasks.withType(Jar).configureEach { duplicatesStrategy = DuplicatesStrategy.EXCLUDE }

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenLocal()
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'net.logstash.logback:logstash-logback-encoder:7.4'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

// Liquibase
liquibaseRuntime 'org.liquibase:liquibase-core:4.27.0'
liquibaseRuntime 'info.picocli:picocli:4.7.5'
liquibaseRuntime 'com.microsoft.sqlserver:mssql-jdbc:12.6.1.jre11'
}

tasks.named('test') {
useJUnitPlatform()
}

jar {
manifest {
attributes(
'Main-Class': 'gov.cdc.etldatapipeline.EtlDataPipelineApplication'
)
}
zip64 true
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

// Gather all runtime dependencies
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
}

apply plugin: "org.liquibase.gradle"

ext {
NBS_DB_VER = '15.1'
}

liquibase {
activities {
odse_main {
changelogFile "./src/main/resources/db/changelog/db.master.changelog-${NBS_DB_VER}.yaml"
url "jdbc:sqlserver://${System.env.DB_URL}:1433;databaseName=master;encrypt=true;trustServerCertificate=true"
username "${System.env.DB_USERNAME}"
password "${System.env.DB_PASSWORD}"
}
odse_main {
changelogFile "./src/main/resources/db/changelog/db.odse.changelog-${NBS_DB_VER}.yaml"
url "jdbc:sqlserver://${System.env.DB_URL}:1433;databaseName=${System.env.DB_ODSE};encrypt=true;trustServerCertificate=true"
username "${System.env.DB_USERNAME}"
password "${System.env.DB_PASSWORD}"
}
rdb_main {
changelogFile "./src/main/resources/db/changelog/db.rdb.changelog-${NBS_DB_VER}.yaml"
url "jdbc:sqlserver://${System.env.DB_URL}:1433;databaseName=${System.env.DB_RDB};encrypt=true;trustServerCertificate=true"
username "${System.env.DB_USERNAME}"
password "${System.env.DB_PASSWORD}"
}
}
}

sonarqube {
properties {
property "sonar.sourceEncoding", "UTF-8"
property "sonar.projectKey", "CDCgov_NEDSS-DataAccess"
property "sonar.organization", "cdcgov"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.coverage.jacoco.xmlReportPaths", "${rootDir}/investigation-service/build/customJacocoReportDir/test/jacocoTestReport.xml," +
"${rootDir}/ldfdata-service/build/customJacocoReportDir/test/jacocoTestReport.xml,${rootDir}/observation-service/build/customJacocoReportDir/test/jacocoTestReport.xml,${rootDir}/person-service/build/customJacocoReportDir/test/jacocoTestReport.xml," +
"${rootDir}/post-processing-service/build/customJacocoReportDir/test/jacocoTestReport.xml"
}
}
48 changes: 48 additions & 0 deletions liquibase-service/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh
set -e

BASE="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

#DA_PATH=$BASE/nedss-dataaccess/builder/ #Uncomment for copying from github repo

# Clone NEDSSDev
#rm -rf $DA_PATH
#cp -r $HOME/'GitPrj/NEDSS-DataAccess/data-reporting-service/' $DA_PATH

#VERSION=master
#git clone -b $VERSION [email protected]:cdcent/NEDSS-DataAccess.git $DA_PATH

# Build and deploy database containers
echo "Building SQL Server database"
docker-compose -f $BASE/docker-compose.yml up nbs-dataaccess-mssql --build -d

# Build and deploy Zookeeper container
echo "Building Zookeeper"
docker-compose -f $BASE/docker-compose.yml up zookeeper --build -d

# Build and deploy Kafka Broke container
echo "Building Kafka Broker"
docker-compose -f $BASE/docker-compose.yml up broker --build -d

# Build and deploy ETL Data pipeline container
echo "Building the Liquibase Service"
docker-compose -f $BASE/docker-compose.yml up liquibase-service --build -d

echo "Building Person Reporting Service"
docker-compose -f $BASE/docker-compose.yml up person-reporting-service --build -d

# Cleanup
#rm -rf $DA_PATH

echo "**** NEDSS DataAccess ETL Data Pipeline build complete ****"
echo "Reporting Service Health Check"
echo "http://localhost:8081/status"
echo ""
echo "Person Reporting Service Health Check"
echo "http://localhost:8090/status"
echo ""
echo "Database: localhost:1433"
echo "DB user: sa"
echo "DB password: fake.fake.fake.1234"
echo "Kafka: localhost:9092"
echo ""
Binary file not shown.
7 changes: 7 additions & 0 deletions liquibase-service/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 0bd3ade

Please sign in to comment.