Skip to content

Commit

Permalink
Merge pull request #33 from KPMP/develop
Browse files Browse the repository at this point in the history
Release v2.3
  • Loading branch information
rlreamy authored Mar 26, 2024
2 parents c81a966 + 25fb98e commit 11746a6
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.*
*.iml
gradle
src
build/*
!build/docker
49 changes: 49 additions & 0 deletions .github/workflows/build-gradle-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build hubble-data docker image

on:
push:

jobs:
build-gradle-project:
env:
IMAGE_TAG: 2.3
runs-on: ubuntu-latest
steps:
- name: Get branch names
id: branch-names
uses: tj-actions/branch-names@v8

- name: Get current branch name
if: steps.branch-names.outputs.is_default == 'false'
run: |
echo "Running on branch: ${{ steps.branch-names.outputs.current_branch }}"
- name: Checkout project sources
uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.4

- name: Login to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.ENV_DOCKER_USER }}
password: ${{ secrets.ENV_DOCKER_PASS }}

- name: Run build with Gradle Wrapper
run: |
./gradlew build docker
- name: Push to Docker Hub if branch is develop
if: steps.branch-names.outputs.current_branch == 'develop'
run: |
docker push "kingstonduo/hubble-data:$IMAGE_TAG"
- name: Push to Docker Hub if branch is not develop
if: ${{ !steps.branch-names.outputs.current_branch == 'develop' }}
run: |
docker push "kingstonduo/hubble-data:${{ steps.branch-names.outputs.current_branch }}"
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM openjdk:8-jdk-alpine
FROM alpine:3.19.1

RUN apk update
RUN apk add openjdk8

VOLUME /tmp
ARG DEPENDENCY=target/dependency

Expand All @@ -10,4 +14,4 @@ RUN apk add --no-cache tzdata
ENV TZ=America/Detroit
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ENTRYPOINT ["java","-cp","app:app/lib/*","org.kpmp.Application"]
ENTRYPOINT ["java","-cp","app:app/lib/*","org.kpmp.Application"]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ If you have having troubles seeing changes during development, you can try to cl
# Build

`./gradlew build docker`
The default tag is the github branch name if no verison is provided
To pass a version when building the docker image execute
`./gradlew build docker -Ptag=<tagNumber>`

# Restart Spring

Expand Down
27 changes: 25 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ apply plugin: 'io.spring.dependency-management'

jar {
baseName='hubble-data'
version= '1.0'
version= '2.3'
}

repositories {
Expand Down Expand Up @@ -59,8 +59,31 @@ task unpack(type: Copy) {
into("build/dependency")
}

def getTagInfo() {
if (project.hasProperty('tag')) {
def tagValue = project.property('tag')
return tagValue
} else {
def gitBranch = "Unknown branch"
try {
def workingDir = new File("${project.projectDir}")
def result = 'git rev-parse --abbrev-ref HEAD'.execute(null, workingDir)
result.waitFor()
if (result.exitValue() == 0) {
gitBranch = result.text.trim()
}
} catch (e) {
}
if (gitBranch == "develop" || gitBranch == "master"){
return "${jar.version}"
}else{
return gitBranch
}
}
}

docker {
name "${project.group}/${jar.baseName}:latest"
name "${project.group}/${jar.baseName}:" + getTagInfo()
copySpec.from(tasks.unpack.outputs).into("dependency")
buildArgs(['DEPENDENCY': "dependency"])
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class SpatialViewerDatasetService {
private String enterpriseSearchEngineName;
private SpatialViewerExternalLinkRepository externalLinkRepo;
private SpatialViewerFileDatasetRepository fileRepo;
@Value("${recently-released-date}")
private String recentlyReleasedDate;

private RestTemplate restTemplate;
private Environment env;
Expand Down Expand Up @@ -73,7 +75,7 @@ public List<SpatialViewerDataset> getSpatialViewerDataset() throws Exception {
for (SpatialViewerFileDataset spatialViewerFileDataset : datasets){
if(spatialViewerFileDataset.getReleaseVersion() != null){
if (Double.compare(spatialViewerFileDataset.getReleaseVersion(), maxReleaseVersion) == EQUALITY_OPERATOR){
spatialViewerFileDataset.setReleaseVersionDisplay("Recently Released");
spatialViewerFileDataset.setReleaseVersionDisplay("Recently Released - " + recentlyReleasedDate);
}
}else{
spatialViewerFileDataset.setReleaseVersionDisplay(null);
Expand All @@ -84,7 +86,7 @@ public List<SpatialViewerDataset> getSpatialViewerDataset() throws Exception {
for(SpatialViewerExternalLinkDataset externalLinkDataset : externalLinkList){
if(externalLinkDataset.getReleaseVersion() != null){
if(Double.compare(externalLinkDataset.getReleaseVersion(), maxReleaseVersion) == EQUALITY_OPERATOR){
externalLinkDataset.setReleaseVersionDisplay("Recently Released");
externalLinkDataset.setReleaseVersionDisplay("Recently Released - " + recentlyReleasedDate);
}
}else{
externalLinkDataset.setReleaseVersionDisplay(null);
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
server.port=3030
spring.main.allow-bean-definition-overriding=true
enterprise-search.host=http://enterprisesearch:3002
enterprise-search.engine.name=spatial-viewer
enterprise-search.engine.name=spatial-viewer
recently-released-date=${RECENTLY_RELEASED_DATE}

0 comments on commit 11746a6

Please sign in to comment.