Skip to content

Commit 363f2cf

Browse files
Merge pull request #34 from kit-data-manager/development
Prepare 0.1.2
2 parents 337081f + 3de2b53 commit 363f2cf

File tree

10 files changed

+422
-95
lines changed

10 files changed

+422
-95
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
# Publish `master` as Docker `latest` image.
6+
branches:
7+
- main
8+
9+
# Publish `v1.2.3` tags as releases.
10+
tags:
11+
- v*
12+
13+
# Run tests for any PRs.
14+
pull_request:
15+
16+
env:
17+
# TODO: Change variable to your image's name.
18+
IMAGE_NAME: indexing-service
19+
# JDK version used for building jar file
20+
currentBuildVersion: 17
21+
22+
jobs:
23+
# Run tests.
24+
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
25+
test:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout repo
30+
uses: actions/checkout@v2
31+
- name: Set up OpenJDK version ...
32+
uses: actions/setup-java@v2
33+
with:
34+
distribution: 'zulu'
35+
java-version: ${{ env.currentBuildVersion }}
36+
- name: Pull elasticsearch image from docker
37+
run: docker pull elasticsearch:7.9.3
38+
- name: Install python
39+
run: sudo apt-get install --assume-yes python3 python3-setuptools python3-pip
40+
- name: Update pip
41+
run: pip3 install --upgrade pip
42+
- name: Install libraries via pip (xmltodict and wget)
43+
run: pip3 install xmltodict wget
44+
- name: Grant execute permission for gradlew
45+
run: chmod +x gradlew
46+
- name: Run tests
47+
run: ./gradlew jacocoTestReport
48+
# docker build . --file Dockerfile
49+
# Push image to GitHub Packages.
50+
# See also https://docs.docker.com/docker-hub/builds/
51+
push:
52+
# Ensure test job passes before pushing image.
53+
needs: test
54+
55+
runs-on: ubuntu-latest
56+
if: github.event_name == 'push'
57+
58+
steps:
59+
- name: Checkout repo
60+
uses: actions/checkout@v2
61+
62+
- name: Build image
63+
run: |
64+
docker build . --file Dockerfile --tag $IMAGE_NAME
65+
- name: Log into registry
66+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
67+
68+
- name: Push image
69+
run: |
70+
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
71+
# Change all uppercase to lowercase
72+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
73+
# Strip git ref prefix from version
74+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
75+
# Strip "v" prefix from tag name
76+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
77+
# Use Docker `latest` tag convention
78+
[ "$VERSION" == "main" ] && VERSION=latest
79+
echo IMAGE_ID=$IMAGE_ID
80+
echo VERSION=$VERSION
81+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
82+
docker push $IMAGE_ID:$VERSION
83+
- name: Docker meta
84+
id: docker_meta
85+
uses: crazy-max/ghaction-docker-meta@v1
86+
with:
87+
# list of Docker images to use as base name for tags
88+
images: |
89+
kitdm/indexing-service
90+
# add git short SHA as Docker tag
91+
tag-sha: true
92+
- name: Set up QEMU
93+
uses: docker/setup-qemu-action@v1
94+
95+
- name: Set up Docker Buildx
96+
uses: docker/setup-buildx-action@v1
97+
- name: Login to DockerHub
98+
uses: docker/login-action@v1
99+
with:
100+
username: ${{ secrets.DOCKER_USERNAME }}
101+
password: ${{ secrets.DOCKER_PASSWORD }}
102+
103+
- name: Push to Docker Hub
104+
uses: docker/build-push-action@v2
105+
with:
106+
context: .
107+
push: true
108+
tags: ${{ steps.docker_meta.outputs.tags }}
109+
labels: ${{ steps.docker_meta.outputs.labels }}

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Changed
1111

12+
## [0.1.2] - date 2023-02-07
13+
### Fixed
14+
- Dockerfile for dockerhub
15+
16+
### Changed
17+
- Bump mockito-core from 5.0.0 to 5.1.1
18+
- Bump javersVersion from 6.8.2 to 6.9.1
19+
- Bump postgresql from 42.5.1 to 42.5.3
20+
- Bump tika-core from 2.6.0 to 2.7.0
21+
1222
## [0.1.1] - date 2023-01-30
1323
### Changed
1424
- Bump mockito-core from 4.8.1 to 5.0.0 by @dependabot in https://github.com/kit-data-manager/indexing-service/pull/20
@@ -52,7 +62,8 @@ and mapping of metadata documents delivered by RabbitMQ
5262
- Mapping of metadata documents with Gemma
5363
- Ingest to elasticsearch
5464

55-
[Unreleased]: https://github.com/kit-data-manager/indexing-service/compare/v0.1.1...HEAD
65+
[Unreleased]: https://github.com/kit-data-manager/indexing-service/compare/v0.1.2...HEAD
66+
[0.1.2]: https://github.com/kit-data-manager/indexing-service/compare/v0.1.1...v0.1.2
5667
[0.1.1]: https://github.com/kit-data-manager/indexing-service/compare/v0.1.0...v0.1.1
5768
[0.1.0]: https://github.com/kit-data-manager/indexing-service/compare/v0.0.4...v0.1.0
5869
[0.0.4]: https://github.com/kit-data-manager/indexing-service/compare/v0.0.3...v0.0.4

Dockerfile

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ ARG SERVICE_ROOT_DIRECTORY_DEFAULT=/spring/
1111
####################################################
1212
# Building environment (java & git)
1313
####################################################
14-
FROM openjdk:11-buster AS build-env-java
14+
FROM python:3.10 AS build-env-java
1515
LABEL maintainer=webmaster@datamanager.kit.edu
1616
LABEL stage=build-env
1717

1818
# Install git as additional requirement
1919
RUN apt-get update && \
20-
apt-get upgrade --assume-yes && \
21-
apt-get install --assume-yes git
20+
apt-get upgrade --no-install-recommends --assume-yes && \
21+
apt-get install --no-install-recommends --assume-yes git && \
22+
apt-get install --no-install-recommends --assume-yes openjdk-17-jdk && \
23+
apt-get clean && \
24+
rm -rf /var/lib/apt/lists/*
2225

2326
####################################################
2427
# Building service
2528
####################################################
26-
FROM build-env-java AS build-service-metastore2
29+
FROM build-env-java AS build-service-indexing
2730
LABEL maintainer=webmaster@datamanager.kit.edu
2831
LABEL stage=build-contains-sources
2932

@@ -42,12 +45,12 @@ COPY . .
4245
RUN cp settings/application-docker.properties settings/application-default.properties
4346

4447
# Build service in given directory
45-
RUN bash ./build.sh $SERVICE_DIRECTORY
48+
RUN bash ./build4docker.sh $SERVICE_DIRECTORY
4649

4750
####################################################
48-
# Runtime environment 4 metastore2
51+
# Runtime environment 4 indexing-service
4952
####################################################
50-
FROM openjdk:11-buster AS run-service-metastore2
53+
FROM python:3.10 AS run-service-indexing
5154
LABEL maintainer=webmaster@datamanager.kit.edu
5255
LABEL stage=run
5356

@@ -61,17 +64,20 @@ ENV REPO_NAME=${REPO_NAME_DEFAULT}
6164
ENV SERVICE_DIRECTORY=${SERVICE_ROOT_DIRECTORY_DEFAULT}${REPO_NAME}
6265
ENV REPO_PORT=${REPO_PORT_DEFAULT}
6366

64-
# Install python3 & pip3 as additional requirement
67+
# Install JDK17
6568
RUN apt-get update && \
66-
apt-get upgrade --assume-yes && \
67-
apt-get install --assume-yes python3 python3-pip
69+
apt-get upgrade --no-install-recommends --assume-yes && \
70+
apt-get install --no-install-recommends --assume-yes openjdk-17-jdk && \
71+
apt-get clean && \
72+
rm -rf /var/lib/apt/lists/*
6873

69-
RUN pip3 install xmltodict wget
74+
# Install python3 & pip3 as additional requirement
75+
RUN pip3 install --no-cache-dir xmltodict==0.13.0 wget==3.2
7076

7177
# Copy service from build container
7278
RUN mkdir -p ${SERVICE_DIRECTORY}
7379
WORKDIR ${SERVICE_DIRECTORY}
74-
COPY --from=build-service-metastore2 ${SERVICE_DIRECTORY} ./
80+
COPY --from=build-service-indexing ${SERVICE_DIRECTORY} ./
7581

7682
ENV PYTHONIOENCODING=UTF-8
7783

build.gradle

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
id "io.spring.dependency-management" version "1.1.0"
44
id "io.freefair.lombok" version "6.6.1"
55
id "io.freefair.maven-publish-java" version "6.6.1"
6-
id "org.owasp.dependencycheck" version "8.0.1"
6+
id "org.owasp.dependencycheck" version "8.0.2"
77
id 'org.asciidoctor.jvm.convert' version '3.3.2'
88
id 'net.researchgate.release' version '3.0.2'
99
id "com.gorylenko.gradle-git-properties" version "2.4.1"
@@ -13,7 +13,7 @@ plugins {
1313

1414
ext {
1515
// versions of dependencies
16-
javersVersion = '6.8.2'
16+
javersVersion = '6.9.1'
1717
springDocVersion = '1.6.14'
1818
}
1919

@@ -71,12 +71,12 @@ dependencies {
7171
implementation "org.springdoc:springdoc-openapi-webmvc-core:${springDocVersion}"
7272

7373
// driver for postgres
74-
implementation "org.postgresql:postgresql:42.5.1"
74+
implementation "org.postgresql:postgresql:42.5.3"
7575
//driver for h2
7676
implementation "com.h2database:h2:2.1.214"
7777

7878
//apache
79-
implementation "org.apache.tika:tika-core:2.6.0"
79+
implementation "org.apache.tika:tika-core:2.7.0"
8080
implementation "commons-codec:commons-codec:1.15"
8181

8282
implementation "com.github.jknack:handlebars:4.3.1"
@@ -93,7 +93,7 @@ dependencies {
9393
// actuator
9494
implementation 'de.codecentric:spring-boot-admin-starter-client:2.7.10'
9595

96-
runtimeOnly 'org.apache.httpcomponents:httpclient:4.5.6'
96+
runtimeOnly 'org.apache.httpcomponents:httpclient:4.5.14'
9797

9898
// Additional libraries for tests
9999
testImplementation "com.google.guava:guava:31.1-jre"
@@ -102,7 +102,7 @@ dependencies {
102102
testImplementation "org.springframework.security:spring-security-test"
103103

104104
//Java 11 Support
105-
testImplementation "org.mockito:mockito-core:5.0.0"
105+
testImplementation "org.mockito:mockito-core:5.1.1"
106106
testImplementation "junit:junit:4.13.2"
107107

108108
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc:2.0.7.RELEASE'
@@ -129,39 +129,6 @@ bootJar {
129129
launchScript()
130130
}
131131

132-
task prepareElastic(type:Exec) {
133-
println 'Start elasticsearch container'
134-
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
135-
println '##################################################################'
136-
println 'ATTENTION: Please start elasticsearch by your own!'
137-
println '##################################################################'
138-
} else {
139-
commandLine "bash", "./manageIndexingFramework.sh", "test"
140-
}
141-
}
142-
143-
task stopElastic(type:Exec) {
144-
println 'Stop elasticsearch container'
145-
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
146-
println '##################################################################'
147-
println 'ATTENTION: Please stop elasticsearch by your own!'
148-
println '##################################################################'
149-
} else {
150-
commandLine "bash", "./manageIndexingFramework.sh", "stop_test"
151-
}
152-
}
153-
154-
test {
155-
dependsOn prepareElastic
156-
finalizedBy stopElastic, jacocoTestReport
157-
environment "spring.config.location", "classpath:/test-config/"
158-
159-
testLogging {
160-
outputs.upToDateWhen {false}
161-
showStandardStreams = true
162-
}
163-
}
164-
165132
jacoco {
166133
toolVersion = "0.8.8"
167134
}

build.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,14 @@ function checkParameters {
5050
# Check if directory exists
5151
if [ ! -d "$INSTALLATION_DIRECTORY" ]; then
5252
# Create directory if it doesn't exists.
53-
mkdir -p "$INSTALLATION_DIRECTORY"
54-
if [ $? -ne 0 ]; then
53+
if ! mkdir -p "$INSTALLATION_DIRECTORY"; then
5554
echo "Error creating directory '$INSTALLATION_DIRECTORY'!"
5655
echo "Please make sure that you have the correct access permissions for the specified directory."
5756
exit 1
5857
fi
5958
fi
6059
# Check if directory is empty
61-
if [ ! -z "$(ls -A "$INSTALLATION_DIRECTORY")" ]; then
60+
if [ -n "$(ls -A "$INSTALLATION_DIRECTORY")" ]; then
6261
echo "Directory '$INSTALLATION_DIRECTORY' is not empty!"
6362
echo "Please enter an empty or a new directory!"
6463
exit 1
@@ -74,7 +73,7 @@ it 1; }
7473
function printInfo {
7574
################################################################################
7675
echo "---------------------------------------------------------------------------"
77-
echo $*
76+
echo "$*"
7877
echo "---------------------------------------------------------------------------"
7978
}
8079

@@ -89,8 +88,7 @@ testForCommands="chmod cp dirname find java javac mkdir sed"
8988

9089
for command in $testForCommands
9190
do
92-
type $command >> /dev/null
93-
if [ $? -ne 0 ]; then
91+
if ! type "$command" >> /dev/null; then
9492
echo "Error: command '$command' is not installed!"
9593
exit 1
9694
fi
@@ -121,11 +119,11 @@ printInfo "Build microservice of $REPO_NAME at '$INSTALLATION_DIRECTORY'"
121119
################################################################################
122120

123121
echo Build service...
124-
./gradlew -Prelease clean build
122+
./gradlew -Dprofile=release clean build
125123

126124

127125
echo "Copy configuration to '$INSTALLATION_DIRECTORY'..."
128-
find . -name application-default.properties -exec sed -e "s/src\/test\/resources\/python/scripts\/python/g" '{}' > "$INSTALLATION_DIRECTORY"/application.properties \;
126+
find ./settings -name application-default.properties -exec cp '{}' "$INSTALLATION_DIRECTORY"/application.properties \;
129127

130128
echo "Copy jar file to '$INSTALLATION_DIRECTORY'..."
131129
find . -name "$REPO_NAME*.jar" -exec cp '{}' "$INSTALLATION_DIRECTORY" \;

0 commit comments

Comments
 (0)