Skip to content

Commit

Permalink
Merge pull request #18 from KPMP/KPMP-5100_build-image-with-gradle
Browse files Browse the repository at this point in the history
KPMP-5100_build-image-with-gradle
  • Loading branch information
rlreamy authored Feb 6, 2024
2 parents 0d25a87 + 556d1cc commit 1523345
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build-gradle-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build hydra-data docker image

on:
push:

jobs:
build-gradle-project:
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: '21'
distribution: 'oracle'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 8.5

- 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
docker push "kingstonduo/hydra-data:${{ steps.branch-names.outputs.current_branch }}"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine
FROM alpine:3.19.1

RUN apk update && \
apk upgrade
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ If you have having troubles seeing changes during development, you can try to cl
4. SSH to the appropriate KE machine
5. Execute:
`curl -X GET http://localhost:3050/api/v1/repository/load-search`

# Pushing images to Docker
This repository is equipped to build and push an image to docker hub when pushing to the repository (except for master and develop). The image will be named `kingstonduo/hydra-data:<git-branch-name>`
19 changes: 18 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ plugins {

group = 'kingstonduo'

def getCurrentGitBranch() {
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) {
}
return gitBranch
}


apply plugin: 'java'
apply plugin: 'eclipse'
Expand Down Expand Up @@ -56,8 +70,11 @@ task unpack(type: Copy) {
into("build/dependency")
}




docker {
name "${project.group}/hydra-data:latest"
name "${project.group}/hydra-data:" + getCurrentGitBranch()
copySpec.from(tasks.unpack.outputs).into("dependency")
buildArgs(['DEPENDENCY': "dependency"])
}

0 comments on commit 1523345

Please sign in to comment.