Split build.sh to build and docker image creation

This commit is contained in:
2026-06-09 14:46:58 +02:00
parent b02484aded
commit f2e3889d8f
2 changed files with 62 additions and 33 deletions
+4 -33
View File
@@ -1,8 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
JREVERSION=25.0.2-0
export VERSION=$(git describe --tags --exact-match 2>/dev/null \
|| git symbolic-ref --short -q HEAD \
|| git rev-parse --short HEAD)
@@ -11,36 +9,9 @@ GITHASH=$(git rev-parse --short=8 HEAD)
export VERSION_LONG=${VERSION}_${GITHASH}
# Build this artifact
echo "Building 'NenjimHub v${VERSION_LONG}'..."
./gradlew -Pversion=$VERSION jar prepareLibs
# Prepare container dependencies
mkdir -p build/docker/{conf,libs}
cd build/docker
cp ../../src/main/docker/run.sh run.sh
cp ../libs/*.jar libs/
cp ../../conf/* conf/
sed -e "s|_VERSION_|${VERSION}|g" \
-e "s|_JREVERSION_|${JREVERSION}|g" \
../../src/main/docker/Dockerfile_template > Dockerfile
# Build the container
GROUP=r35157
NAME=nenjimhub
BASETAG=dockerreg.r35157.com/${GROUP}/${NAME}
HASHTAG=${BASETAG}:${GITHASH}_amd64
VERSIONTAG=${BASETAG}:${VERSION}_amd64
LATESTTAG=${BASETAG}:latest_amd64
CANONICALNAME=${HASHTAG}
docker build -t ${CANONICALNAME} .
docker tag ${CANONICALNAME} ${VERSIONTAG}
docker tag ${CANONICALNAME} ${LATESTTAG}
# Prepare publishing script
sed -e "s|_HASHTAG_|${HASHTAG}|g" \
-e "s|_VERSIONTAG_|${VERSIONTAG}|g" \
-e "s|_LATESTTAG_|${LATESTTAG}|g" \
../../src/main/docker/publish_template.sh > publish.sh
chmod 755 publish.sh
./gradlew \
-Pversion=${VERSION} \
jar \
prepareLibs