#26 Dockerize
This commit is contained in:
13
build/Dockerfile
Normal file
13
build/Dockerfile
Normal 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
86
build/Jenkinsfile
vendored
Normal 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
8
build/pixi.toml
Normal 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
20
build/settings.xml
Normal 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>
|
||||
12
pom.xml
12
pom.xml
@@ -31,26 +31,26 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>18</java.version>
|
||||
<scmDeveloperConnectionProp />
|
||||
<repository.url>http://192.168.10.4:8100</repository.url>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>77zzcx7-snapshots</id>
|
||||
<url>http://192.168.10.4:8100/snapshots/</url>
|
||||
<url>${repository.url}/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>77zzcx7-releases</id>
|
||||
<url>http://192.168.10.4:8100/releases/</url>
|
||||
<url>${repository.url}/releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://77zzcx7.de/gitea/MK13/NoBullShit-cloud.git</connection>
|
||||
<developerConnection>${scmDeveloperConnectionProp}</developerConnection>
|
||||
<developerConnection>scm:git:https://77zzcx7.de/gitea/MK13/NoBullShit-cloud.git</developerConnection>
|
||||
<url>https://77zzcx7.de/gitea/MK13/NoBullShit-cloud</url>
|
||||
<tag>v14</tag>
|
||||
</scm>
|
||||
<tag>v14</tag>
|
||||
</scm>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
Reference in New Issue
Block a user