This commit is contained in:
FyloZ 2021-02-11 19:38:11 -05:00
parent f0302bc3cd
commit aa35b410d3
2 changed files with 68 additions and 2 deletions

View File

@ -1,6 +1,8 @@
variables:
CI_REGISTRY_IMAGE_GRADLE: "$CI_REGISTRY_IMAGE:latest-backend-gradle"
CI_REGISTRY_IMAGE_NG: "$CI_REGISTRY_IMAGE:latest-frontend-ng"
CI_REGISTRY_IMAGE_BACKEND: "$CI_REGISTRY_IMAGE:latest-backend"
CI_REGISTRY_IMAGE_FRONTEND: "$CI_REGISTRY_IMAGE:latest-frontend"
before_script:
- docker info
@ -16,9 +18,32 @@ 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 build --cache-from $CI_REGISTRY_IMAGE_GRADLE -f gradle.Dockerfile -t $CI_REGISTRY_IMAGE_GRADLE --build-arg JDK_VERSION=$JDK_VERSION --build-arg GRADLE_VERSION=$GRADLE_VERSION .
- docker push $CI_REGISTRY_IMAGE_GRADLE
build-frontend:
stage: build
script:
- docker pull $CI_REGISTRY_IMAGE_NG || true
- docker build --cache-from $CI_REGISTRY_IMAGE_NG -f ng.Dockerfile -t $CI_REGISTRY_IMAGE_NG --build-arg JDK_VERSION=$JDK_VERSION --build-arg GRADLE_VERSION=$GRADLE_VERSION .
- docker push $CI_REGISTRY_IMAGE_NG
compile-kotlin-backend:
stage: test
needs: ['build-backend']
variables:
COMPILE_KOTLIN_CONTAINER_NAME: "cre_backend_gradle_compile_kotlin"
script:
- docker run --name $COMPILE_KOTLIN_CONTAINER_NAME --rm $CI_REGISTRY_IMAGE_GRADLE gradle compileKotlin
compile-java-backend:
stage: test
needs: ['build-backend']
variables:
COMPILE_JAVA_CONTAINER_NAME: "cre_backend_gradle_compile_java"
script:
- docker run --name $COMPILE_JAVA_CONTAINER_NAME --rm $CI_REGISTRY_IMAGE_JAVA gradle compileJava
test-backend:
stage: test
needs: ['build-backend']
@ -31,7 +56,7 @@ package-backend:
stage: package
needs: ['test-backend']
variables:
PACKAGE_CONTAINER_NAME: "cre_backend_gradle_package"
PACKAGE_CONTAINER_NAME: "cre_backend_package"
ARTIFACT_NAME: "ColorRecipesExplorer-$CI_PIPELINE_IID"
script:
- docker run --name $PACKAGE_CONTAINER_NAME $CI_REGISTRY_IMAGE_GRADLE gradle buildBackend
@ -39,11 +64,34 @@ package-backend:
- docker rm $PACKAGE_CONTAINER_NAME
- docker build -t $CI_REGISTRY_IMAGE_BACKEND -f backend.Dockerfile --build-arg PORT=$BACKEND_PORT --build-arg ARTIFACT_NAME=$ARTIFACT_NAME .
- docker push $CI_REGISTRY_IMAGE_BACKEND
after_script:
- docker stop $PACKAGE_CONTAINER_NAME || true
artifacts:
paths:
- ColorRecipesExplorer-$CI_PIPELINE_IID.jar
expire_in: 1 week
package-frontend:
stage: package
needs: ['test-frontend']
variables:
PACKAGE_CONTAINER_NAME: "cre_frontend_package"
ARTIFACT_NAME: "ColorRecipesExplorer-$CI_PIPELINE_IID-ng"
before_script:
- apk update
- apk add --no-cache zip
- mkdir dist
script:
- docker run --name $PACKAGE_CONTAINER_NAME $CI_REGISTRY_IMAGE_NG gradle buildFrontend
- docker cp $PACKAGE_CONTAINER_NAME:/usr/src/mcd/dist/frontend/ dist/
- zip -r $ARTIFACT_NAME.zip dist/
after_script:
- docker stop $PACKAGE_CONTAINER_NAME || true
artifacts:
paths:
- $ARTIFACT_NAME.zip
expire_in: 1 week
.before_deploy: &before_deploy
before_script:
- apk update

18
ng.Dockerfile Normal file
View File

@ -0,0 +1,18 @@
ARG JDK_VERSION=11
ARG GRADLE_VERSION=6.8
FROM gradle:$GRADLE_VERSION-jdk$JDK_VERSION
WORKDIR /usr/src/cre/
RUN apt update
RUN apt install nodejs -y
RUN apt install npm -y
RUN apt install zip -y
ENV NG_CLI_ANALYTICS=ci
COPY build.gradle.kts .
COPY settings.gradle.kts .
COPY ./src/main/frontend ./src/main/frontend
WORKDIR /usr/src/cre/src/main/frontend