added docker swarm support + auto deploy
nclazz/www.nclazz.de/pipeline/head This commit looks good Details

master
Niclas Thobaben 2022-02-09 20:35:42 +01:00
parent 8626343d28
commit 28cedd6686
18 changed files with 85 additions and 37 deletions

8
.idea/.gitignore vendored
View File

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../../../:\nclazz.de\src\www\www.nclazz.de\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_12" project-jdk-name="12" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/www.nclazz.de.iml" filepath="$PROJECT_DIR$/.idea/www.nclazz.de.iml" />
</modules>
</component>
</project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

2
Dockerfile 100644
View File

@ -0,0 +1,2 @@
FROM docker.nclazz.de/nclazz/static-webserver:latest
COPY ./site .

71
Jenkinsfile vendored 100644
View File

@ -0,0 +1,71 @@
pipeline {
agent any
environment {
DOCKER_REGISTRY = "docker.nclazz.de"
DOCKER_GROUP = 'nclazz'
DOCKER_IMAGE = 'site'
DOCKER_TAG = 'latest'
DEPLOY_NODE = "${ BRANCH_NAME == "master" ? "swarm && prod" : "swarm && staging" }"
SERVICE_NAME = 'marrone-international'
}
stages {
stage('Run Docker Build') {
agent { label 'docker' }
steps {
sh 'chmod +x version.sh'
sh './version.sh > site/version.json'
script {
docker.withRegistry("https://$DOCKER_REGISTRY", "jenkins_nexus") {
def image = docker.build("nclazz/site")
image.push("${env.DOCKER_TAG}")
}
}
}
}
stage('Run Deployment') {
agent { label "provision" }
when {
branch 'master'
}
steps {
deployToSwarm(
name: 'www-nclazz',
file: "${env.WORKSPACE}/docker-compose.yml",
forceUpdate: true,
askApproval: false,
slackChannel: 'deployment'
)
}
}
}
post {
always {
cleanWs()
}
failure {
slackSend(
channel: 'notifications',
color: 'danger',
message: "There is a *build failure* in ${env.JOB_NAME}.\nBuild: ${env.BUILD_URL} "
)
}
unstable {
slackSend(
channel: 'notifications',
color: 'warning',
message: "Some tests have failed in ${env.JOB_NAME}.\nBuild: ${env.BUILD_URL} "
)
}
fixed {
slackSend(
channel: 'notifications',
color: 'good',
message: "The build ${env.JOB_NAME} completed successfully and is back to normal.\nBuild: ${env.BUILD_URL} "
)
}
}
}

10
docker-compose.yml 100644
View File

@ -0,0 +1,10 @@
version: '3.8'
services:
site:
deploy:
replicas: 2
placement:
max_replicas_per_node: 1
image: docker.nclazz.de/nclazz/site:latest
ports:
- 9082:80

View File

Before

Width:  |  Height:  |  Size: 236 B

After

Width:  |  Height:  |  Size: 236 B

View File

Before

Width:  |  Height:  |  Size: 291 B

After

Width:  |  Height:  |  Size: 291 B

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

2
version.sh 100644
View File

@ -0,0 +1,2 @@
#!/bin/bash
echo "{ \"commit\": \"$GIT_COMMIT\", \"build\": \"$BUILD_ID\" }"