Refactor GitLab CI/CD pipelines

This commit is contained in:
2025-05-02 10:41:38 +02:00
parent a557a7efd0
commit 2253e9a3a8
4 changed files with 47 additions and 46 deletions

16
ci-templates.yml Normal file
View File

@@ -0,0 +1,16 @@
.docker_build_template:
image: docker:20.10@sha256:2967f0819c84dd589ed0a023b9d25dcfe7a3c123d5bf784ffbb77edf55335f0c
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login "$CI_REGISTRY" -u "$CI_REGISTRY_USER" --password-stdin
script:
- cd $DOCKER_CONTEXT
- |
echo "Building Docker image for $DOCKER_IMAGE with tag $TAG"
docker build $DOCKER_BUILD_ARGS -t $DOCKER_IMAGE:$TAG -f $DOCKERFILE .
- |
if [[ "$RAW_TAG" == "dev" || "$RAW_TAG" == "production" ]]; then
echo "Pushing Docker image $DOCKER_IMAGE:$TAG"
docker push $DOCKER_IMAGE:$TAG
else
echo "Skipping Docker push for non-dev or production branch: $RAW_TAG"
fi