Compare commits
9 Commits
cd8d00bd8d
...
0.1-dev
| Author | SHA256 | Date | |
|---|---|---|---|
| 214a9b7322 | |||
| ce76ce8977 | |||
| bc661c9e54 | |||
| f9a6183ad1 | |||
| 77121d7251 | |||
| e93f06784c | |||
| 8f907324ca | |||
| a2fae04892 | |||
| d3e859a094 |
@@ -39,7 +39,6 @@ dependencies {
|
|||||||
compileOnly("org.jetbrains:annotations:26.0.2-1")
|
compileOnly("org.jetbrains:annotations:26.0.2-1")
|
||||||
|
|
||||||
implementation("com.r35157.nenjim:hubd-api:0.1-dev")
|
implementation("com.r35157.nenjim:hubd-api:0.1-dev")
|
||||||
implementation("org.apache.poi:poi-ooxml:5.5.1")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
@@ -50,20 +49,25 @@ tasks.withType<JavaCompile>().configureEach {
|
|||||||
options.release.set(25)
|
options.release.set(25)
|
||||||
}
|
}
|
||||||
|
|
||||||
val dockerLibsDir = layout.buildDirectory.dir("docker/libs")
|
val libsDir = layout.buildDirectory.dir("libs")
|
||||||
|
|
||||||
tasks.register<Sync>("prepareDockerLibs") {
|
tasks.register<Sync>("prepareLibs") {
|
||||||
group = "distribution"
|
group = "distribution"
|
||||||
description = "Copies all runtime dependencies (transitive) to build/docker/libs"
|
description = "Copies runtime deps to build/libs without deleting the app jar"
|
||||||
|
|
||||||
// Hvis du også vil bygge dit eget jar samtidig, så lad den stå – ellers kan du fjerne den.
|
val jarTask = tasks.named<Jar>("jar")
|
||||||
dependsOn(tasks.named("jar"))
|
dependsOn(jarTask)
|
||||||
|
|
||||||
into(dockerLibsDir)
|
into(libsDir)
|
||||||
|
|
||||||
// Kun deps (transitivt)
|
// Kun deps (transitivt)
|
||||||
from(configurations.runtimeClasspath)
|
from(configurations.runtimeClasspath)
|
||||||
|
|
||||||
|
// Bevar jar-filen som jar-tasken allerede har lagt i build/libs
|
||||||
|
preserve {
|
||||||
|
include(jarTask.get().archiveFileName.get())
|
||||||
|
}
|
||||||
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
34
build.sh
34
build.sh
@@ -1,6 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
JREVERSION=25.0.2-0
|
||||||
|
|
||||||
export VERSION=$(git describe --tags --exact-match 2>/dev/null \
|
export VERSION=$(git describe --tags --exact-match 2>/dev/null \
|
||||||
|| git symbolic-ref --short -q HEAD \
|
|| git symbolic-ref --short -q HEAD \
|
||||||
|| git rev-parse --short HEAD)
|
|| git rev-parse --short HEAD)
|
||||||
@@ -11,20 +13,34 @@ export VERSION_LONG=${VERSION}_${GITHASH}
|
|||||||
|
|
||||||
# Build this artifact
|
# Build this artifact
|
||||||
echo "Building 'NenjimHub v${VERSION_LONG}'..."
|
echo "Building 'NenjimHub v${VERSION_LONG}'..."
|
||||||
./gradlew -Pversion=$VERSION jar prepareDockerLibs
|
./gradlew -Pversion=$VERSION jar prepareLibs
|
||||||
|
|
||||||
# Prepare container dependencies
|
# Prepare container dependencies
|
||||||
mkdir -p build/docker/conf
|
mkdir -p build/docker/{conf,libs}
|
||||||
cd build/docker
|
cd build/docker
|
||||||
sed -e 's/_VERSION_/'"${VERSION}"'/g' ../../src/main/docker/Dockerfile_template > Dockerfile
|
cp ../../src/main/docker/run.sh run.sh
|
||||||
cp ../../src/main/docker/start.sh start.sh
|
cp ../libs/*.jar libs/
|
||||||
cp ../libs/hubd-impl-ref-*.jar libs
|
cp ../../conf/* conf/
|
||||||
cp ../../conf/* conf
|
sed -e "s|_VERSION_|${VERSION}|g" \
|
||||||
|
-e "s|_JREVERSION_|${JREVERSION}|g" \
|
||||||
|
../../src/main/docker/Dockerfile_template > Dockerfile
|
||||||
|
|
||||||
# Build the container
|
# Build the container
|
||||||
docker build -t r35157/nenjimhub:${VERSION}_amd64 .
|
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
|
# Prepare publishing script
|
||||||
docker tag r35157/nenjimhub:${VERSION}_amd64 r35157/nenjimhub:latest
|
sed -e "s|_HASHTAG_|${HASHTAG}|g" \
|
||||||
sed -e 's/_VERSION_/'"${VERSION}"'/g' ../../src/main/docker/publish_template > publish.sh
|
-e "s|_VERSIONTAG_|${VERSIONTAG}|g" \
|
||||||
|
-e "s|_LATESTTAG_|${LATESTTAG}|g" \
|
||||||
|
../../src/main/docker/publish_template.sh > publish.sh
|
||||||
chmod 755 publish.sh
|
chmod 755 publish.sh
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
export VERSION=$(git describe --tags --exact-match 2>/dev/null \
|
|
||||||
|| git symbolic-ref --short -q HEAD \
|
|
||||||
|| git rev-parse --short HEAD)
|
|
||||||
|
|
||||||
echo "Publishing artifact ($VERSION)..."
|
|
||||||
./gradlew -Pversion=$VERSION publish
|
|
||||||
|
|
||||||
echo "Publishing docker container ($VERSION)..."
|
|
||||||
./build/docker/publish.sh
|
|
||||||
1
publishCICD.sh
Symbolic link
1
publishCICD.sh
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
publish.sh
|
||||||
5
run.sh
5
run.sh
@@ -1,5 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
export LOG4J_CONFIGURATION_FILE="$PWD/conf/log4j2.xml"
|
|
||||||
./gradlew run --args="foo bar baz"
|
|
||||||
@@ -1 +1 @@
|
|||||||
rootProject.name = "hubd-impl-ref"
|
rootProject.name = "hubd-impl_ref"
|
||||||
|
|||||||
@@ -1,39 +1,43 @@
|
|||||||
FROM dockerreg.r35157.com/r35157/jre:24.0.1-4_amd64
|
FROM dockerreg.r35157.com/r35157/jre:_JREVERSION__amd64
|
||||||
|
|
||||||
LABEL maintainer="Minimons <minimons@r35157.com>"
|
LABEL maintainer="Minimons <minimons@r35157.com>"
|
||||||
|
|
||||||
# Setup environment
|
# Setup environment
|
||||||
ENV NENJIMHUB_HOME=/usr/local/software/nenjimhub
|
ENV APP_HOME=/usr/local/software/nenjimhub
|
||||||
WORKDIR /usr/local/software
|
WORKDIR /usr/local/software
|
||||||
USER root
|
USER root
|
||||||
RUN mkdir nenjimhub-_VERSION_
|
|
||||||
RUN ln -s nenjimhub-_VERSION_ nenjimhub
|
RUN mkdir nenjimhub-_VERSION_ \
|
||||||
|
&& ln -s nenjimhub-_VERSION_ nenjimhub
|
||||||
WORKDIR nenjimhub
|
WORKDIR nenjimhub
|
||||||
RUN mkdir libs
|
RUN mkdir libs
|
||||||
|
|
||||||
# These dirs are expected to be overshadowed by host mounts
|
# These dirs are expected to be overshadowed by host mounts
|
||||||
RUN mkdir conf logs in out archive
|
RUN mkdir conf logs && chown user:user logs
|
||||||
|
|
||||||
# Install basic tools
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get install -y procps
|
|
||||||
|
|
||||||
# Set timezone
|
# Set timezone
|
||||||
ENV TZ=Europe/Copenhagen
|
ENV TZ=Europe/Copenhagen
|
||||||
|
RUN apt-get update
|
||||||
RUN apt-get install -y tzdata \
|
RUN apt-get install -y tzdata \
|
||||||
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
|
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
|
||||||
&& echo $TZ > /etc/timezone \
|
&& echo $TZ > /etc/timezone \
|
||||||
&& dpkg-reconfigure -f noninteractive tzdata
|
&& dpkg-reconfigure -f noninteractive tzdata
|
||||||
|
|
||||||
# Clean-up
|
# Clean-up
|
||||||
RUN apt-get autoremove \
|
RUN apt-get autoremove -y \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install application and configuration (Do this as late as possible to be able to reuse layers between builds)
|
# Install application and configuration (Do this as late as possible to be able to reuse layers between builds)
|
||||||
COPY start.sh .
|
COPY run.sh .
|
||||||
COPY conf/* conf
|
COPY conf/* conf/
|
||||||
COPY libs/*.jar libs
|
COPY libs/*.jar libs/
|
||||||
|
|
||||||
CMD ["./start.sh"]
|
RUN chown root:root -R conf
|
||||||
|
RUN chmod 755 ./run.sh \
|
||||||
|
&& chmod -R a+rX /usr/local/software/nenjimhub-_VERSION_
|
||||||
|
|
||||||
|
USER user:user
|
||||||
|
|
||||||
|
CMD ["./run.sh"]
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
NAME=nenjimhub
|
|
||||||
VERSION=_VERSION__amd64
|
|
||||||
|
|
||||||
VTAG=dockerreg.r35157.com/r35157/${NAME}:${VERSION}
|
|
||||||
LTAG=dockerreg.r35157.com/r35157/${NAME}:latest
|
|
||||||
|
|
||||||
docker tag r35157/${NAME}:${VERSION} ${VTAG}
|
|
||||||
docker tag r35157/${NAME}:${VERSION} ${LTAG}
|
|
||||||
|
|
||||||
echo "Publishing of '${VTAG}' and '${LTAG}'..."
|
|
||||||
docker push ${VTAG}
|
|
||||||
docker push ${LTAG}
|
|
||||||
|
|
||||||
echo "Publishing completed!"
|
|
||||||
9
src/main/docker/publish_template.sh
Normal file
9
src/main/docker/publish_template.sh
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "Publishing '_HASHTAG_', '_VERSIONTAG_' and '_LATESTTAG_'..."
|
||||||
|
docker push _HASHTAG_
|
||||||
|
docker push _VERSIONTAG_
|
||||||
|
docker push _LATESTTAG_
|
||||||
|
|
||||||
|
echo "Publishing completed!"
|
||||||
17
src/main/docker/run.sh
Executable file
17
src/main/docker/run.sh
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
shopt -s nullglob
|
||||||
|
|
||||||
|
jars=(libs/*.jar)
|
||||||
|
if (( ${#jars[@]} == 0 )); then
|
||||||
|
echo "ERROR: No JARs found in libs/" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CLASSPATH=$(IFS=:; echo "${jars[*]}")
|
||||||
|
|
||||||
|
exec java \
|
||||||
|
-Dlog4j.configurationFile=conf/log4j2.xml \
|
||||||
|
-cp "$CLASSPATH" \
|
||||||
|
com.r35157.nenjim.hubd.impl.ref.Main
|
||||||
@@ -17,6 +17,3 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- /home/op/nenjimhub/conf:/usr/local/software/nenjimhub/conf
|
- /home/op/nenjimhub/conf:/usr/local/software/nenjimhub/conf
|
||||||
- /home/op/nenjimhub/logs:/usr/local/software/nenjimhub/logs
|
- /home/op/nenjimhub/logs:/usr/local/software/nenjimhub/logs
|
||||||
- /home/op/nenjimhub/in:/usr/local/software/nenjimhub/in
|
|
||||||
- /home/op/nenjimhub/out:/usr/local/software/nenjimhub/out
|
|
||||||
- /home/op/nenjimhub/archive:/usr/local/software/nenjimhub/archive
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
CLASSPATH=$(echo libs/*.jar | tr ' ' ':')
|
|
||||||
|
|
||||||
java -Dlog4j.configurationFile=conf/log4j2.xml -cp "$CLASSPATH" com.r35157.nenjim.hubd.impl.ref.Main
|
|
||||||
sleep 100000
|
|
||||||
@@ -5,17 +5,27 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) throws Exception {
|
static void main(String[] args) throws Exception {
|
||||||
new Main();
|
try {
|
||||||
|
new Main(args).service();
|
||||||
|
} catch(Throwable t) {
|
||||||
|
log.error("Error initializing NenjimHub - " + t.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Main() throws Exception {
|
public Main(String[] args) throws Exception {
|
||||||
|
hub = new NenjimHubImpl();
|
||||||
log.info("Initializing NenjimHub...");
|
log.info("Initializing NenjimHub...");
|
||||||
log.info("Ready!");
|
log.info("Ready!");
|
||||||
nenjimHub.noop();
|
|
||||||
|
hub.noop();
|
||||||
Thread.sleep(Long.MAX_VALUE);
|
Thread.sleep(Long.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Logger log = LogManager.getLogger(Main.class);
|
private void service() throws Exception {
|
||||||
private static final NenjimHub nenjimHub = new NenjimHubImpl();
|
}
|
||||||
|
|
||||||
|
private static final Logger log = LogManager.getLogger(Main.class);
|
||||||
|
|
||||||
|
private final NenjimHub hub;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.r35157.nenjim.hubd.impl.ref;
|
package com.r35157.nenjim.hubd.impl.ref;
|
||||||
|
|
||||||
import com.r35157.nenjim.hubd.NenjimHub;
|
import com.r35157.nenjim.hubd.NenjimHub;
|
||||||
|
import com.r35157.nenjim.hubd.NenjimJournal;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class NenjimHubImpl implements NenjimHub {
|
public class NenjimHubImpl implements NenjimHub {
|
||||||
@Override
|
@Override
|
||||||
@@ -10,5 +12,11 @@ public class NenjimHubImpl implements NenjimHub {
|
|||||||
log.debug("NOOP executed.");
|
log.debug("NOOP executed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void monitorJournal(@NotNull NenjimJournal nenjimJournal) {
|
||||||
|
log.warn("monitorJournal IS NOT IMPLEMENTED!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final Logger log = LogManager.getLogger(NenjimHubImpl.class);
|
private static final Logger log = LogManager.getLogger(NenjimHubImpl.class);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user