setup docker and jenkins
nclazz/gitea-bot/pipeline/head There was a failure building this commit
Details
nclazz/gitea-bot/pipeline/head There was a failure building this commit
Details
parent
36413fa535
commit
48ae451416
|
@ -79,7 +79,6 @@ web_modules/
|
|||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
@ -104,7 +103,6 @@ dist
|
|||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
FROM node:16.16.0-alpine3.16
|
||||
|
||||
COPY src/* .
|
||||
COPY package.json package.json
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
RUN npm install
|
||||
|
||||
CMD ["node"]
|
|
@ -0,0 +1,88 @@
|
|||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
NEXUS = credentials('jenkins_nexus')
|
||||
NCLAZZ = credentials('nclazz_api_token')
|
||||
|
||||
DOCKER_REGISTRY = "docker.nclazz.de"
|
||||
DOCKER_GROUP = 'nclazz-bots'
|
||||
DOCKER_IMAGE = 'gitea-bot'
|
||||
DOCKER_TAG = "${ BRANCH_NAME == "master" ? "latest" : "develop" }"
|
||||
DOCKER_VERSION = "1.0.0"
|
||||
|
||||
DEPLOY_ENV = "production"
|
||||
}
|
||||
|
||||
options {
|
||||
timeout(time: 30, unit: "MINUTES")
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Docker Build') {
|
||||
agent { label 'docker' }
|
||||
steps {
|
||||
script {
|
||||
docker.withRegistry("https://$DOCKER_REGISTRY", "jenkins_nexus") {
|
||||
def apiImage = docker.build("$DOCKER_GROUP/$DOCKER_IMAGE")
|
||||
apiImage.push("${env.DOCKER_VERSION}")
|
||||
apiImage.push("${env.DOCKER_TAG}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Run Deployment') {
|
||||
agent { label 'provision' }
|
||||
when {
|
||||
branch 'master'
|
||||
}
|
||||
steps {
|
||||
deployToSwarm(
|
||||
name: 'nclazz-gitea-bot',
|
||||
file: "${env.WORKSPACE}/docker-compose.yml",
|
||||
forceUpdate: true,
|
||||
askApproval: false,
|
||||
slackChannel: 'deployment',
|
||||
env: [
|
||||
PORT: 7007,
|
||||
VERSION: env.DOCKER_VERSION,
|
||||
AUTH_TOKEN: env.NCLAZZ
|
||||
]
|
||||
)
|
||||
exposeService(
|
||||
name: 'nclazz-gitea-bot',
|
||||
fqdn: 'gitea-bot.nclazz.de',
|
||||
description: 'Gitea bot',
|
||||
location: '/',
|
||||
backendPort: 7007
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
failure {
|
||||
slackSend(
|
||||
channel: "notifications",
|
||||
color: "danger",
|
||||
message: "There is a *build failure* in ${env.JOB_NAME}.\nBuild: ${env.RUN_DISPLAY_URL} "
|
||||
)
|
||||
}
|
||||
unstable {
|
||||
slackSend(
|
||||
channel: "notifications",
|
||||
color: "warning",
|
||||
message: "Some tests have failed in ${env.JOB_NAME}.\nBuild: ${env.RUN_DISPLAY_URL} "
|
||||
)
|
||||
}
|
||||
fixed {
|
||||
slackSend(
|
||||
channel: "notifications",
|
||||
color: "good",
|
||||
message: "The build ${env.JOB_NAME} completed successfully and is back to normal.\nBuild: ${env.RUN_DISPLAY_URL} "
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
version: '3.8'
|
||||
services:
|
||||
service:
|
||||
image: docker.nclazz.de/nclazz-bots/gitea-bot:$VERSION
|
||||
environment:
|
||||
SPRING_MAIL_USERNAME: "${MAIL_USERNAME}"
|
||||
SPRING_MAIL_PASSWORD: "${MAIL_PASSWORD}"
|
||||
SPRING_DATASOURCE_USERNAME: "${DB_USERNAME}"
|
||||
SPRING_DATASOURCE_PASSWORD: "${DB_PASSWORD}"
|
||||
SPRING_PROFILES_ACTIVE: swarm
|
||||
NCLAZZ_AUTH_TOKEN: "${AUTH_TOKEN}"
|
||||
deploy:
|
||||
replicas: 1
|
||||
placement:
|
||||
max_replicas_per_node: 1
|
||||
update_config:
|
||||
order: start-first
|
||||
ports:
|
||||
- "${PORT}:8080"
|
|
@ -9,6 +9,8 @@
|
|||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.20.0",
|
||||
"dotenv": "^16.0.1",
|
||||
"express": "^4.18.1"
|
||||
}
|
||||
},
|
||||
|
@ -141,6 +143,15 @@
|
|||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.0.1",
|
||||
"resolved": "https://nexus.nclazz.de/repository/npm_public/dotenv/-/dotenv-16.0.1.tgz",
|
||||
"integrity": "sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://nexus.nclazz.de/repository/npm_public/ee-first/-/ee-first-1.1.1.tgz",
|
||||
|
@ -735,6 +746,11 @@
|
|||
"resolved": "https://nexus.nclazz.de/repository/npm_public/destroy/-/destroy-1.2.0.tgz",
|
||||
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg=="
|
||||
},
|
||||
"dotenv": {
|
||||
"version": "16.0.1",
|
||||
"resolved": "https://nexus.nclazz.de/repository/npm_public/dotenv/-/dotenv-16.0.1.tgz",
|
||||
"integrity": "sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ=="
|
||||
},
|
||||
"ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://nexus.nclazz.de/repository/npm_public/ee-first/-/ee-first-1.1.1.tgz",
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
"author": "Niclas Thobaben",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.20.0",
|
||||
"dotenv": "^16.0.1",
|
||||
"express": "^4.18.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
require('dotenv').config()
|
||||
|
||||
require('./server')
|
|
@ -0,0 +1,13 @@
|
|||
const express = require('express')
|
||||
const bodyParser = require('body-parser')
|
||||
|
||||
console.log('Initialize express server')
|
||||
|
||||
const app = express()
|
||||
|
||||
app.use(bodyParser.json())
|
||||
|
||||
const port = process.env.SERVER_PORT || 8080
|
||||
|
||||
app.listen(port)
|
||||
console.log(`Started express server on port ${port}`)
|
Loading…
Reference in New Issue