5cea825bc0
Remove artifacts uploading from the build stage. Since we use a shared docker socket on the same runner host, the package stage can access the locally built jar file directly without needing gitlab coordinator upload/download.
55 lines
1.3 KiB
YAML
55 lines
1.3 KiB
YAML
variables:
|
|
GRADLE_OPTS: -Dorg.gradle.daemon=false
|
|
DOCKER_HOST: unix:///var/run/docker.sock
|
|
|
|
stages:
|
|
- build
|
|
- package
|
|
- deploy
|
|
|
|
build:
|
|
stage: build
|
|
image: amazoncorretto:21-alpine
|
|
cache:
|
|
key: gradle
|
|
paths:
|
|
- .gradle/wrapper
|
|
- .gradle/caches
|
|
before_script:
|
|
- chmod +x gradlew
|
|
script:
|
|
- ./gradlew bootJar -x test -PartefactVersion="$CI_COMMIT_TAG"
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
package:
|
|
stage: package
|
|
image: docker:27
|
|
needs:
|
|
- build
|
|
script:
|
|
- JAR_FILE=$(find build/libs -name '*.jar' | head -1)
|
|
- echo "Building Docker image for tag $CI_COMMIT_TAG with JAR $JAR_FILE"
|
|
- docker build
|
|
--provenance=false
|
|
-f Dockerfile.ci
|
|
--build-arg JAR_FILE="$JAR_FILE"
|
|
-t "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
|
|
.
|
|
- docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" "$CI_REGISTRY_IMAGE:latest"
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
deploy:
|
|
stage: deploy
|
|
image: docker:27
|
|
needs:
|
|
- package
|
|
script:
|
|
- echo "Pushing image $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
|
|
- docker login "$CI_REGISTRY" -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
|
|
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
|
|
- docker push "$CI_REGISTRY_IMAGE:latest"
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|