-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
37 lines (31 loc) · 1.13 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
plugins {
id "eu.xenit.docker" version "5.3.2"
id 'be.vbgn.ci-detect' version '0.5.0'
}
ext {
base_img = 'open-source.docker.xenit.eu/oracle-python'
base_img_version = 'main-2.1.1'
img_version = '2.2.1'
}
createDockerFile {
from "${base_img}:${base_img_version}"
smartCopy "$project.projectDir/src/main/docker/docker_root", '/'
runCommand "yum install -y python3.11-psycopg2"
runCommand "pip3.11 install --no-cache-dir -r /requirements.txt"
entryPoint '/swarmclean.py'
}
dockerBuild {
repositories = ['private.docker.xenit.eu/alfred-ops/swarmclean']
tags = generateDockerImageTags()
}
def generateDockerImageTags() {
String timestamp = new Date().format('yyyyMMddHHmmss')
String branch = ci.reference ?: 'local'
if (branch == 'local')
// Only used in local docker-compose.yml
return ["local-${img_version}", "local-${img_version}-" + timestamp]
if (branch == 'master')
return ["${img_version}-" + timestamp]
// Replace all non-alphanumeric characters by '_' to sanitize for image tag
return [branch.replaceAll('\\W', '_') + "-${img_version}-" + timestamp]
}