Replace command line Docker image build with Gradle Jib plugin
This commit is contained in:
committed by
Petri Tuomola
parent
b2dbbe66de
commit
6e052e536b
@@ -9,7 +9,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Build the image
|
- name: Build the image
|
||||||
run: docker-compose build
|
run: ./gradlew :fineract-provider:jibDockerBuild -x test
|
||||||
- name: Start the stack
|
- name: Start the stack
|
||||||
run: docker-compose up -d
|
run: docker-compose up -d
|
||||||
- name: Wait for stack to come up
|
- name: Wait for stack to come up
|
||||||
|
|||||||
-50
@@ -1,50 +0,0 @@
|
|||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
# or more contributor license agreements. See the NOTICE file
|
|
||||||
# distributed with this work for additional information
|
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
|
||||||
# to you under the Apache License, Version 2.0 (the
|
|
||||||
# "License"); you may not use this file except in compliance
|
|
||||||
# with the License. You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing,
|
|
||||||
# software distributed under the License is distributed on an
|
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
# KIND, either express or implied. See the License for the
|
|
||||||
# specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
#
|
|
||||||
FROM azul/zulu-openjdk-debian:11 AS builder
|
|
||||||
|
|
||||||
RUN apt-get update -qq && apt-get install -y wget
|
|
||||||
|
|
||||||
COPY . fineract
|
|
||||||
WORKDIR /fineract
|
|
||||||
|
|
||||||
RUN ./gradlew --no-daemon -q -x rat -x compileTestJava -x test -x spotlessJavaCheck -x spotlessJava bootJar
|
|
||||||
|
|
||||||
WORKDIR /fineract/target
|
|
||||||
RUN jar -xf /fineract/fineract-provider/build/libs/fineract-provider.jar
|
|
||||||
|
|
||||||
# We download separately a JDBC driver (which not allowed to be included in Apache binary distribution)
|
|
||||||
WORKDIR /fineract/target/BOOT-INF/libs
|
|
||||||
RUN wget -q https://downloads.mariadb.com/Connectors/java/connector-java-2.7.3/mariadb-java-client-2.7.3.jar
|
|
||||||
|
|
||||||
# =========================================
|
|
||||||
|
|
||||||
FROM azul/zulu-openjdk-alpine:11 AS fineract
|
|
||||||
|
|
||||||
COPY --from=builder /fineract/target/BOOT-INF/lib /app/lib
|
|
||||||
COPY --from=builder /fineract/target/META-INF /app/META-INF
|
|
||||||
COPY --from=builder /fineract/target/BOOT-INF/classes /app
|
|
||||||
|
|
||||||
WORKDIR /
|
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
|
||||||
|
|
||||||
RUN chmod 775 /entrypoint.sh
|
|
||||||
|
|
||||||
EXPOSE 8443
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
|
||||||
@@ -118,7 +118,7 @@ Now to run a new Fineract instance you can simply:
|
|||||||
|
|
||||||
1. `git clone https://github.com/apache/fineract.git ; cd fineract`
|
1. `git clone https://github.com/apache/fineract.git ; cd fineract`
|
||||||
1. for windows, use `git clone https://github.com/apache/fineract.git --config core.autocrlf=input ; cd fineract`
|
1. for windows, use `git clone https://github.com/apache/fineract.git --config core.autocrlf=input ; cd fineract`
|
||||||
1. `docker-compose build`
|
1. `./gradlew :fineract-provider:jibDockerBuild -x test`
|
||||||
1. `docker-compose up -d`
|
1. `docker-compose up -d`
|
||||||
1. fineract (back-end) is running at https://localhost:8443/fineract-provider/
|
1. fineract (back-end) is running at https://localhost:8443/fineract-provider/
|
||||||
1. wait for https://localhost:8443/fineract-provider/actuator/health to return `{"status":"UP"}`
|
1. wait for https://localhost:8443/fineract-provider/actuator/health to return `{"status":"UP"}`
|
||||||
@@ -126,8 +126,6 @@ Now to run a new Fineract instance you can simply:
|
|||||||
1. community-app (UI) is running at http://localhost:9090/?baseApiUrl=https://localhost:8443/fineract-provider&tenantIdentifier=default
|
1. community-app (UI) is running at http://localhost:9090/?baseApiUrl=https://localhost:8443/fineract-provider&tenantIdentifier=default
|
||||||
1. login using default _username_ `mifos` and _password_ `password`
|
1. login using default _username_ `mifos` and _password_ `password`
|
||||||
|
|
||||||
The [`docker-compose.yml`](docker-compose.yml) will build the `fineract` container from the source based on the [`Dockerfile`](Dockerfile). You could change that to use the pre-built container image instead of having to re-build it.
|
|
||||||
|
|
||||||
https://hub.docker.com/r/apache/fineract has a pre-built container image of this project, built continuously.
|
https://hub.docker.com/r/apache/fineract has a pre-built container image of this project, built continuously.
|
||||||
|
|
||||||
You must specify the MySQL tenants database JDBC URL by passing it to the `fineract` container via environment
|
You must specify the MySQL tenants database JDBC URL by passing it to the `fineract` container via environment
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ plugins {
|
|||||||
id 'org.asciidoctor.jvm.revealjs' version '3.3.2' apply false
|
id 'org.asciidoctor.jvm.revealjs' version '3.3.2' apply false
|
||||||
id 'org.asciidoctor.jvm.gems' version '3.3.2' apply false
|
id 'org.asciidoctor.jvm.gems' version '3.3.2' apply false
|
||||||
id 'org.asciidoctor.kindlegen.base' version '3.2.0' apply false
|
id 'org.asciidoctor.kindlegen.base' version '3.2.0' apply false
|
||||||
|
id "com.google.cloud.tools.jib" version "3.1.4" apply false
|
||||||
id "org.sonarqube" version "3.3"
|
id "org.sonarqube" version "3.3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -36,9 +36,9 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
fineract-server:
|
fineract-server:
|
||||||
build:
|
image: fineract:latest
|
||||||
context: .
|
volumes:
|
||||||
target: fineract
|
- ./fineract-provider/build/data:/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", 'sh', '-c', 'echo -e "Checking for the availability of Fineract server deployment"; while ! nc -z "fineract-server" 8443; do sleep 1; printf "-"; done; echo -e " >> Fineract server has started";' ]
|
test: ["CMD", 'sh', '-c', 'echo -e "Checking for the availability of Fineract server deployment"; while ! nc -z "fineract-server" 8443; do sleep 1; printf "-"; done; echo -e " >> Fineract server has started";' ]
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
# or more contributor license agreements. See the NOTICE file
|
|
||||||
# distributed with this work for additional information
|
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
|
||||||
# to you under the Apache License, Version 2.0 (the
|
|
||||||
# "License"); you may not use this file except in compliance
|
|
||||||
# with the License. You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing,
|
|
||||||
# software distributed under the License is distributed on an
|
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
# KIND, either express or implied. See the License for the
|
|
||||||
# specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
# NOTE that we are limited to busybox's sh, and cannot use bash here, because
|
|
||||||
# this is used in a container image based on azul/zulu-openjdk-alpine:17.
|
|
||||||
|
|
||||||
# see e.g. https://explainshell.com/explain?cmd=set+-eux
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
while ! nc -zvw3 "${FINERACT_DEFAULT_TENANTDB_HOSTNAME:-fineractmysql}" "${FINERACT_DEFAULT_TENANTDB_PORT:-3306}" ; do
|
|
||||||
>&2 echo "DB Server is unavailable - sleeping"
|
|
||||||
sleep 5
|
|
||||||
done
|
|
||||||
>&2 echo "DB Server is up - executing command"
|
|
||||||
|
|
||||||
java -cp "app:app/lib/*" org.apache.fineract.ServerApplication
|
|
||||||
@@ -27,6 +27,7 @@ apply plugin: 'com.gorylenko.gradle-git-properties'
|
|||||||
apply plugin: 'io.swagger.core.v3.swagger-gradle-plugin'
|
apply plugin: 'io.swagger.core.v3.swagger-gradle-plugin'
|
||||||
apply plugin: 'distribution'
|
apply plugin: 'distribution'
|
||||||
apply plugin: 'signing'
|
apply plugin: 'signing'
|
||||||
|
apply plugin: 'com.google.cloud.tools.jib'
|
||||||
|
|
||||||
// Configuration for the OpenJPA enhance task
|
// Configuration for the OpenJPA enhance task
|
||||||
// https://github.com/radcortez/openjpa-gradle-plugin
|
// https://github.com/radcortez/openjpa-gradle-plugin
|
||||||
@@ -246,6 +247,52 @@ bootJar {
|
|||||||
classifier = ''
|
classifier = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jib {
|
||||||
|
from {
|
||||||
|
image = 'azul/zulu-openjdk-alpine:11'
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
image = 'fineract'
|
||||||
|
tags = [
|
||||||
|
"${releaseVersion}",
|
||||||
|
'latest'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
container {
|
||||||
|
creationTime = 'USE_CURRENT_TIMESTAMP'
|
||||||
|
mainClass = 'org.apache.fineract.ServerApplication'
|
||||||
|
jvmFlags = [
|
||||||
|
'-Xmx1G',
|
||||||
|
'-Xms1G',
|
||||||
|
'-XshowSettings:vm',
|
||||||
|
'-XX:+UseContainerSupport',
|
||||||
|
'-XX:+UseStringDeduplication',
|
||||||
|
'-XX:MinRAMPercentage=25',
|
||||||
|
'-XX:MaxRAMPercentage=80'
|
||||||
|
]
|
||||||
|
args = [
|
||||||
|
'-Duser.home=/tmp',
|
||||||
|
'-Dspring.profiles.active=basicauth',
|
||||||
|
'-Dfile.encoding=UTF-8',
|
||||||
|
'-Duser.timezone=UTC',
|
||||||
|
'-Djava.security.egd=file:/dev/./urandom'
|
||||||
|
]
|
||||||
|
ports = ['8080/tcp', '8443/tcp']
|
||||||
|
labels = [maintainer: 'Aleksandar Vidakovic <aleks@apache.org>']
|
||||||
|
user = 'nobody:nogroup'
|
||||||
|
}
|
||||||
|
|
||||||
|
allowInsecureRegistries = true
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation 'org.mariadb.jdbc:mariadb-java-client:2.7.3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.jibDockerBuild.dependsOn = ["bootJar"]
|
||||||
|
|
||||||
tasks.withType(Tar) {
|
tasks.withType(Tar) {
|
||||||
compression Compression.GZIP
|
compression Compression.GZIP
|
||||||
extension 'tar.gz'
|
extension 'tar.gz'
|
||||||
|
|||||||
+5
-2
@@ -45,13 +45,16 @@ public class PersistenceConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@DependsOn("tenantDatabaseUpgradeService")
|
@DependsOn("tenantDatabaseUpgradeService")
|
||||||
public EntityManagerFactory entityManagerFactory() {
|
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||||
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
||||||
em.setDataSource(routingDataSource);
|
em.setDataSource(routingDataSource);
|
||||||
|
// NOTE: very important to set this explicitly when building Docker images with Jib; otherwise complains about
|
||||||
|
// duplicate resources
|
||||||
|
em.setPersistenceXmlLocation("classpath:META-INF/persistence.xml");
|
||||||
em.setJpaVendorAdapter(new OpenJpaVendorAdapter());
|
em.setJpaVendorAdapter(new OpenJpaVendorAdapter());
|
||||||
em.setPersistenceUnitName("jpa-pu");
|
em.setPersistenceUnitName("jpa-pu");
|
||||||
em.afterPropertiesSet();
|
em.afterPropertiesSet();
|
||||||
return em.getObject();
|
return em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
+1
-1
@@ -17,5 +17,5 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
org.gradle.jvmargs=-Xmx2g
|
org.gradle.jvmargs=-Xmx2g
|
||||||
releaseVersion=1.4.0
|
releaseVersion=1.5.0
|
||||||
buildType=BUILD
|
buildType=BUILD
|
||||||
|
|||||||
Reference in New Issue
Block a user