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()
// Retrieve default tag
String defaultTag = sh(returnStdout: true, script: 'git describe --always').trim()
container.buildAndPublishImage([
'imageName': 'reg.cadoles.com/pcaseiro/myapplication-standalone',
// Use current tag or default tag if not defined
'imageTag': defaultTag,
'dockerfile': './misc/images/myapplication-standalone/Dockerfile',
'dryRun': false
])
container.buildAndPublishImage([
'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
])
job('Building docker images') {
steps {
shell('make')
}
}
job('Publishing docker images') {
steps {
shell('make release')
}
}
}
}
]

View File

@ -2,9 +2,11 @@
# Makefile for Cadoles SP
################################
IMAGE_REPO := reg.cadoles.com/cadoles
IMAGE_VERSION ?= 0.0.1
COMMIT_ID ?= $(shell git rev-parse --short --verify HEAD)
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

View File

@ -28,12 +28,12 @@ define install_trivy
endef
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:latest ; \
docker push $(IMAGE_REPO)/$1:latest ; \
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
#list:
@ -57,9 +57,12 @@ release: ${IMAGES_DIR}/*
@for name in $(basename $(notdir $^)); do \
$(call release_image,$${name},base); \
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:
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)-latest
docker push $(IMAGE_FULL_NAME):$(IMAGE_TAG)-$(IMAGE_VERSION)-$(DAY_SUFFIX_TAG)