Skip to content

Commit

Permalink
x86 architecture fix and database import added to judo.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcsakany committed Feb 14, 2023
1 parent 376f889 commit 54dabfc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
14 changes: 7 additions & 7 deletions application/docker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@


<profile>
<id>create-docker-image-amd64</id>
<id>create-docker-image-x86_64</id>
<activation>
<property>
<name>!skipDocker</name>
</property>
<os><arch>x86</arch></os>
<os><arch>x86_64</arch></os>
</activation>
<build>
<plugins>
Expand All @@ -227,7 +227,7 @@
<version>3.3.1</version>
<executions>
<execution>
<id>build-platform-docker-amd64</id>
<id>build-platform-docker-x86_64</id>
<phase>package</phase>
<goals>
<goal>buildTar</goal>
Expand Down Expand Up @@ -268,7 +268,7 @@
</volumes>
</container>
<outputPaths>
<tar>${basedir}/target/${project.parent.artifactId}-${project.version}_docker_image_amd64.tar</tar>
<tar>${basedir}/target/${project.parent.artifactId}-${project.version}_docker_image_x86_64.tar</tar>
</outputPaths>
<extraDirectories>
<paths>
Expand Down Expand Up @@ -297,16 +297,16 @@
<version>3.0.0</version>
<executions>
<execution>
<id>attach-artifacts-amd64</id>
<id>attach-artifacts-x86_64</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${basedir}/target/${project.parent.artifactId}-${project.version}_docker_image_amd64.tar</file>
<classifier>amd64</classifier>
<file>${basedir}/target/${project.parent.artifactId}-${project.version}_docker_image_x86_64.tar</file>
<classifier>x86_64</classifier>
<type>tar</type>
</artifact>
</artifacts>
Expand Down
35 changes: 26 additions & 9 deletions application/judo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ USAGE: judo.sh COMMANDS... [OPTIONS...]
update Update dependency versions in JUDO project.
generate Generate application based on model in JUDO project.
dump Dump postgresql db data before clearing and starting application.
import Import postgresql db data
-dn --dump-name Import dump name when it's not deifined loaded the last one
build Build project.
-a --build-app-module Build app module only.
-M --skip-model Skip model building.
Expand Down Expand Up @@ -147,13 +148,18 @@ get_dashed_ip () {


# Args:
# 1 - instance name
# 2 - instance name
# 1 - dump
import_postgres () {
local dumps=`ls ${APP_DIR}/${APP_NAME}_dump_*.tar.gz`
dumps=dumps=$(echo $dumps | xargs -n1 | sort | xargs)
dumps=$str|tr ' ' '\n'|tac|tr '\n' ' '
local lastdump=${dumps[${#dumps[@]}-1]}
echo "$lastdump"
local INSTANCE_NAME=$1
local image_name=$2
if [ -z $image_name ]; then
local dumps=($(ls ${APP_DIR}/${APP_NAME}_dump_*.tar.gz))
dumps=$dumps | xargs -n1 | sort | xargs
image_name=${dumps[${#dumps[@]} - 1]}
fi
echo "Loading dump: $image_name"
docker exec -i ${INSTANCE_NAME} pg_restore -Fc --clean -U ${APP_NAME} -d ${APP_NAME} < ${image_name}
}

# Args:
Expand Down Expand Up @@ -494,7 +500,6 @@ CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
APP_DIR=$CURR_DIR
MODEL_DIR="$(cd -P -- "$(dirname -- "${APP_DIR}")" && pwd)"

import_postgres

[ $# -eq 0 ] && print-help && exit 0

Expand All @@ -515,7 +520,8 @@ skipFrontend=0
skipKeycloak=0
buildAppModule=0
skipBackendModels=0

import=0
dumpName=''

FULL_VERSION_NUMBER="SNAPSHOT"
original_args=( "$@" )
Expand Down Expand Up @@ -552,6 +558,8 @@ while [ $# -ne 0 ]; do
update) update=1; shift 1;;
generate) generate=1; shift 1;;
dump) dump=1; shift 1;;
import) import=1; shift 1;;
-dn | --dump-name) shift 1; export dumpName=$1; shift 1;;

build) build=1; shift 1;;
-a | --build-app-module) buildAppModule=1; skipModel=1; shift 1;;
Expand Down Expand Up @@ -621,6 +629,15 @@ if [ $dump -eq 1 ]; then
stop_docker_instance postgres-${APP_NAME}
fi

if [ $import -eq 1 ]; then
remove_docker_instance postgres-${APP_NAME}
remove_docker_volume ${APP_NAME}_db
start_postgres postgres-${APP_NAME} ${POSTGRES_PORT:-5432}
wait_for_port 127.0.0.1 ${POSTGRES_PORT:-5432} 30
import_postgres postgres-${APP_NAME}
stop_docker_instance postgres-${APP_NAME}
fi

if [ $prune -eq 1 ]; then
prune_frontend
elif [ $clean -eq 1 ]; then
Expand Down

0 comments on commit 54dabfc

Please sign in to comment.