This commit is contained in:
FyloZ 2021-02-11 13:25:32 -05:00
parent 6f1fe83122
commit d996da5213
2 changed files with 53 additions and 0 deletions

43
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,43 @@
variables:
CI_REGISTRY_IMAGE_GRADLE: "$CI_REGISTRY_IMAGE:latest-backend-gradle"
CI_REGISTRY_IMAGE_BACKEND: "$CI_REGISTRY_IMAGE:latest-backend"
before_script:
- docker info
- docker login -u $CI_USERNAME -p $CI_ACCESS_TOKEN $CI_REGISTRY
stages:
- build
- test
- package
# BUILD
build-backend:
stage: build
script:
- docker pull $CI_REGISTRY_IMAGE_GRADLE || true
- docker build --cache-from $CI_REGISTRY_IMAGE_GRADLE -f gradle.Dockerfile -t $CI_REGISTRY_IMAGE_GRADLE --build-arg JDK_VERSIN=$JDK_VERSION --build-arg GRADLE_VERSION=$GRADLE_VERSION .
- docker push $CI_REGISTRY_IMAGE_GRADLE
test-backend:
stage: test
needs: ['build-backend']
variables:
TEST_CONTAINER_NAME: "cre_backend_gradle_tests"
script:
- docker run --name $TEST_CONTAINER_NAME --rm $CI_REGISTRY_IMAGE_GRADLE gradle test
package-backend:
stage: package
needs: ['test-backend']
variables:
PACKAGE_CONTAINER_NAME: "cre_backend_gradle_package"
script:
- docker run --name $PACKAGE_CONTAINER_NAME $CI_REGISTRY_IMAGE_GRADLE gradle buildBackend
- docker cp $PACKAGE_CONTAINER_NAME:/usr/src/cre/dist/backend/ColorRecipesExplorer.jar ColorRecipesExplorer-$CI_PIPELINE_IID.jar
- docker rm $PACKAGE_CONTAINER_NAME
artifacts:
paths:
- ColorRecipesExplorer-$CI_PIPELINE_IID.jar
expire_in: 1 week

10
gradle.Dockerfile Normal file
View File

@ -0,0 +1,10 @@
ARG JDK_VERSION=11
ARG GRADLE_VERSION=6.8
FROM gradle:$GRADLE_VERSION-jdk$JDK_VERSION
WORKDIR /usr/src/cre/
COPY build.gradle.kts build.gradle.kts
COPY settings.gradle.kts settings.gradle.kts
COPY src src