Compare commits

..

2 Commits

Author SHA1 Message Date
Philippe Caseiro 3a9dc1ae21 fup-try-010 2023-06-19 16:09:06 +02:00
Philippe Caseiro 13ac2b6959 fup 2023-06-19 15:55:07 +02:00
3 changed files with 21 additions and 20 deletions

24
Jenkinsfile vendored
View File

@ -13,20 +13,16 @@ symfonyAppPipeline('ubuntu:22.04', [
String currentTag = sh(script: 'git tag --points-at HEAD | head -n 1', returnStdout: true).trim() String currentTag = sh(script: 'git tag --points-at HEAD | head -n 1', returnStdout: true).trim()
// Retrieve default tag // Retrieve default tag
String defaultTag = sh(returnStdout: true, script: 'git describe --always').trim() String defaultTag = sh(returnStdout: true, script: 'git describe --always').trim()
container.buildAndPublishImage([ job('Building docker images') {
'imageName': 'reg.cadoles.com/pcaseiro/myapplication-standalone', steps {
// Use current tag or default tag if not defined shell('make')
'imageTag': defaultTag, }
'dockerfile': './misc/images/myapplication-standalone/Dockerfile', }
'dryRun': false job('Publishing docker images') {
]) steps {
container.buildAndPublishImage([ shell('make release')
'imageName': 'reg.cadoles.com/pcaseiro/myapplication-kube', }
// Use current tag or default tag if not defined }
'imageTag': defaultTag,
'dockerfile': './misc/images/myapplication-kube/Dockerfile',
'dryRun': false
])
} }
} }
] ]

View File

@ -2,9 +2,11 @@
# Makefile for Cadoles SP # Makefile for Cadoles SP
################################ ################################
IMAGE_REPO := reg.cadoles.com/cadoles COMMIT_ID ?= $(shell git rev-parse --short --verify HEAD)
IMAGE_VERSION ?= 0.0.1 CURRENT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD | tr -c '[:alnum:]\n\r' '_'| tr '[:upper:]' '[:lower:]')
IMAGE_REPO ?= reg.cadoles.com/cadoles
IMAGE_VERSION ?= 0.0.1-$(CURRENT_BRANCH)
DAY_SUFFIX_TAG ?= $(shell date +%Y%m%d)
include main.mk include main.mk

View File

@ -28,12 +28,12 @@ define install_trivy
endef endef
define release_image define release_image
docker tag $(IMAGE_REPO)/$1:$(IMAGE_VERSION) $(IMAGE_REPO)/$1:$(IMAGE_VERSION)-$(DAY_SUFFIX_TAG) ; \ docker tag $(IMAGE_REPO)/$1:$(IMAGE_VERSION) $(IMAGE_REPO)/$1:$(IMAGE_VERSION)-$(COMMIT_ID) ; \
docker tag $(IMAGE_REPO)/$1:$(IMAGE_VERSION) $(IMAGE_REPO)/$1:$(IMAGE_VERSION); \ docker tag $(IMAGE_REPO)/$1:$(IMAGE_VERSION) $(IMAGE_REPO)/$1:$(IMAGE_VERSION); \
docker tag $(IMAGE_REPO)/$1:$(IMAGE_VERSION) $(IMAGE_REPO)/$1:latest ; \ docker tag $(IMAGE_REPO)/$1:$(IMAGE_VERSION) $(IMAGE_REPO)/$1:latest ; \
docker push $(IMAGE_REPO)/$1:latest ; \ docker push $(IMAGE_REPO)/$1:latest ; \
docker push $(IMAGE_REPO)/$1:$(IMAGE_VERSION) ; \ docker push $(IMAGE_REPO)/$1:$(IMAGE_VERSION) ; \
docker push $(IMAGE_REPO)/$1:$(IMAGE_VERSION)-$(DAY_SUFFIX_TAG) docker push $(IMAGE_REPO)/$1:$(IMAGE_VERSION)-$(COMMIT_ID)
endef endef
#list: #list:
@ -57,9 +57,12 @@ release: ${IMAGES_DIR}/*
@for name in $(basename $(notdir $^)); do \ @for name in $(basename $(notdir $^)); do \
$(call release_image,$${name},base); \ $(call release_image,$${name},base); \
done;\ done;\
git tag -f -a $(IMAGE_VERSION) -m "Version $(IMAGE_VERSION) released"; \
git tag -f -a $(IMAGE_VERSION)-$(COMMIT_ID) -m "Version $(IMAGE_VERSION)-$(COMMIT_ID) released"; \
git tag -f -a $(IMAGE_VERSION)-latest -m "Version $(IMAGE_VERSION)-latest released"; \
_release: _release:
docker tag $(IMAGE_FULL_NAME):$(IMAGE_TAG) $(IMAGE_FULL_NAME):$(IMAGE_TAG)-$(IMAGE_VERSION)-$(DAY_SUFFIX_TAG) docker tag $(IMAGE_FULL_NAME):$(IMAGE_TAG) $(IMAGE_FULL_NAME):$(IMAGE_TAG)-$(IMAGE_VERSION)-$(COMMIT_ID)
docker tag $(IMAGE_FULL_NAME):$(IMAGE_TAG) $(IMAGE_FULL_NAME):$(IMAGE_TAG)-$(IMAGE_VERSION) docker tag $(IMAGE_FULL_NAME):$(IMAGE_TAG) $(IMAGE_FULL_NAME):$(IMAGE_TAG)-$(IMAGE_VERSION)
docker tag $(IMAGE_FULL_NAME):$(IMAGE_TAG) $(IMAGE_FULL_NAME):$(IMAGE_TAG)-latest docker tag $(IMAGE_FULL_NAME):$(IMAGE_TAG) $(IMAGE_FULL_NAME):$(IMAGE_TAG)-latest
docker push $(IMAGE_FULL_NAME):$(IMAGE_TAG)-$(IMAGE_VERSION)-$(DAY_SUFFIX_TAG) docker push $(IMAGE_FULL_NAME):$(IMAGE_TAG)-$(IMAGE_VERSION)-$(DAY_SUFFIX_TAG)