1
0
This commit is contained in:
2026-01-17 11:12:53 +01:00
parent 2eab631796
commit 046124464e
5 changed files with 133 additions and 6 deletions

13
build/Dockerfile Normal file
View File

@@ -0,0 +1,13 @@
FROM eclipse-temurin:25-jre-alpine
# Create a non-root user for security
RUN addgroup -S spring && adduser -S spring -G spring
USER spring:spring
ARG JAR_FILE
COPY ${JAR_FILE} app.jar
EXPOSE 8082
ENTRYPOINT ["java", "-jar", "/app.jar"]

86
build/Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,86 @@
pipeline {
agent { label 'docker' }
environment {
REPO_URL = credentials('reposilite-url')
DOCKER_REGISTRY = credentials('docker-registry-url')
}
parameters {
booleanParam(name: 'DRY_RUN', defaultValue: true, description: 'If checked, no code will be pushed to Gitea, Reposilite, or Docker.')
}
stages {
stage('Provision Environment') {
steps {
sh '''
pixi install
pixi shell-hook > .pixi_activate
'''
}
}
stage('Version & Tag') {
steps {
withCredentials([usernamePassword(credentialsId: 'Jenkins_Gitea',
usernameVariable: 'GITEA_CREDS_USR',
passwordVariable: 'GITEA_CREDS_PSW')]) {
sh '''
source .pixi_activate
git config user.email "jenkins@77zzcx7.de"
git config user.name "Jenkins"
git remote set-url origin https://${GITEA_CREDS_USR}:${GITEA_CREDS_PSW}@${GIT_URL_CLEAN}
mvn release:prepare -B \
-s build/settings.xml \
-DdryRun=${DRY_RUN} \
-Dreposilite.url=${REPO_URL} \
-DtagNameFormat="v@{project.version}" \
-Darguments="-Dtag=v${project.version} -DskipTests"
'''
}
}
}
stage('Deploy Release') {
steps {
withCredentials([usernamePassword(credentialsId: 'reposilite-jenkins-cred',
usernameVariable: 'REPO_USER',
passwordVariable: 'REPO_TOKEN')]) {
sh '''
source .pixi_activate
mvn release:perform -B \
-s build/settings.xml \
-DdryRun=${DRY_RUN} \
-Dreposilite.url=${REPO_URL} \
-Darguments="-DskipTests"
'''
}
}
}
stage('Docker Build & Push') {
steps {
script {
def jarPath = sh(script: "ls web-container/target/checkout/target/*.jar | head -n 1", returnStdout: true).trim()
def releaseVer = sh(script: "source .pixi_activate && mvn help:evaluate -Dexpression=project.version -q -DforceStdout -f web-container/target/checkout/pom.xml", returnStdout: true).trim()
docker.withRegistry("${env.DOCKER_REGISTRY}", '') {
def customImage = docker.build("${env.DOCKER_REGISTRY}/my-app:${env.BUILD_ID}",
"-f build/Dockerfile --build-arg JAR_FILE=${jarPath} .")
if (params.DRY_RUN) {
echo "DRY_RUN - do not push image to registry"
}
else {
customImage.push("latest")
}
}
}
}
}
}
}

8
build/pixi.toml Normal file
View File

@@ -0,0 +1,8 @@
[project]
name = "nbscloud"
channels = ["conda-forge"]
platforms = ["linux-64"]
[dependencies]
openjdk = "25.*"
maven = "3.9.*"

20
build/settings.xml Normal file
View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>77zzcx7-releases</id>
<username>${env.REPO_USER}</username>
<password>${env.REPO_TOKEN}</password>
</server>
</servers>
<mirrors>
<mirror>
<id>central</id>
<mirrorOf>*</mirrorOf>
<name>77zzcx7-central</name>
<url>${env.REPO_URL}/releases</url>
</mirror>
</mirrors>
</settings>