From 16d1f2afda49639e28d7a8afecdca80a9f868cc1 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Thu, 5 Aug 2021 23:36:48 -0400 Subject: [PATCH] =?UTF-8?q?#8=20Mise=20=C3=A0=20jour=20CI/CD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 11 ++++++++++ .drone.yml | 55 ++++++++++++++++++++++++++++++----------------- Dockerfile | 22 +++++++++++++------ gradle.Dockerfile | 10 --------- todo.txt | 15 ------------- 5 files changed, 62 insertions(+), 51 deletions(-) create mode 100644 .dockerignore delete mode 100644 gradle.Dockerfile delete mode 100644 todo.txt diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8cdfa43 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.gradle +.idea +**/build +**/data +**/gradle +**/logs +.gitignore +.gitlab-ci.yml +docker-compose.yml +Dockerfile +gradlew** diff --git a/.drone.yml b/.drone.yml index abd9354..c3a9b41 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,38 +1,51 @@ +--- +global-variables: + environment: &environment + JAVA_VERSION: 11 + GRADLE_VERSION: 7.1 + CRE_VERSION: dev-${DRONE_BUILD_NUMBER} + CRE_ARTIFACT_NAME: ColorRecipesExplorer + CRE_REGISTRY_IMAGE: registry.fyloz.dev:5443/colorrecipesexplorer/backend + CRE_PORT: 9101 + gradle-image: &gradle-image gradle:7.1-jdk11 + alpine-image: &alpine-image alpine:latest + docker-registry-repo: &docker-registry-repo registry.fyloz.dev:5443/colorrecipesexplorer/backend + kind: pipeline name: default type: docker -environment: - CRE_VERSION: ${DRONE_BUILD_NUMBER} - CRE_ARTIFACT_NAME: ColorRecipesExplorer - CRE_REGISTRY_IMAGE: registry.fyloz.dev:5443/colorrecipesexplorer/backend - CRE_PORT: 9101 - steps: - - name: test - image: gradle:7.1-jdk11 + - name: set-docker-tags + image: *alpine-image + environment: + <<: *environment commands: - - gradle test + - echo -n "latest,dev-$CRE_VERSION" > .tags + - cat .tags when: branch: develop events: push - - name: build - image: gradle:7.1-jdk11 + - name: gradle-test + image: *gradle-image commands: - - gradle bootJar -Pversion=$CRE_VERSION - - mv build/libs/ColorRecipesExplorer-$CRE_VERSION.jar $CRE_ARTIFACT_NAME.jar - - echo -n "latest,$CRE_VERSION" > .tags + - gradle test when: - branch: master - events: push + branch: develop + events: [push, pull_request] - name: containerize image: plugins/docker + environment: + <<: *environment settings: - build_args: - - JAVA_VERSION=11 - repo: registry.fyloz.dev:5443/colorrecipesexplorer/backend + build_args_from_env: + - GRADLE_VERSION + - JAVA_VERSION + - CRE_VERSION + - CRE_PORT + repo: *docker-registry-repo when: branch: master events: push @@ -40,6 +53,8 @@ steps: - name: deploy image: alpine:latest environment: + <<: *environment + CRE_REGISTRY_IMAGE: *docker-registry-repo DEPLOY_SERVER: from_secret: deploy_server DEPLOY_SERVER_USERNAME: @@ -64,7 +79,7 @@ steps: - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' - ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker stop $DEPLOY_CONTAINER_NAME || true && docker rm $DEPLOY_CONTAINER_NAME || true" - ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker pull $CRE_REGISTRY_IMAGE:latest" - - ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker run -d -p $CRE_PORT:9090 --name=$DEPLOY_CONTAINER_NAME -v $DEPLOY_DATA_VOLUME:/usr/bin/cre/data -v $DEPLOY_CONFIG_VOLUME:/usr/bin/cre/config -e spring_profiles_active=$DEPLOY_SPRING_PROFILES $CRE_REGISTRY_IMAGE" + - ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker run -d -p $CRE_PORT:9090 --name=$DEPLOY_CONTAINER_NAME -v $DEPLOY_DATA_VOLUME:/usr/bin/data -v $DEPLOY_CONFIG_VOLUME:/usr/bin/config -e spring_profiles_active=$DEPLOY_SPRING_PROFILES $CRE_REGISTRY_IMAGE" when: branch: master events: push diff --git a/Dockerfile b/Dockerfile index 3f4a504..66b5bba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,21 @@ +ARG GRADLE_VERSION=7.1 ARG JAVA_VERSION=11 +ARG CRE_VERSION=dev -FROM openjdk:$JAVA_VERSION +FROM gradle:$GRADLE_VERSION-jdk$JAVA_VERSION AS build +WORKDIR /usr/src -WORKDIR /usr/bin/cre/ +COPY . . +RUN gradle bootJar -Pversion=$CRE_VERSION -ARG CRE_ARTIFACT_NAME=ColorRecipesExplorer -COPY $CRE_ARTIFACT_NAME.jar ColorRecipesExplorer.jar +FROM alpine:latest +WORKDIR /usr/bin + +ARG JAVA_VERSION +RUN apk add --no-cache openjdk$JAVA_VERSION + +ARG CRE_VERSION +COPY --from=build /usr/src/build/libs/ColorRecipesExplorer.jar ColorRecipesExplorer.jar ARG CRE_PORT=9090 EXPOSE $CRE_PORT @@ -16,7 +26,7 @@ ENV spring_datasource_url=jdbc:h2:mem:cre ENV spring_datasource_username=root ENV spring_datasource_password=pass -VOLUME /usr/bin/cre/data -VOLUME /usr/bin/cre/config +VOLUME /usr/bin/data +VOLUME /usr/bin/config ENTRYPOINT ["java", "-jar", "ColorRecipesExplorer.jar"] diff --git a/gradle.Dockerfile b/gradle.Dockerfile deleted file mode 100644 index 2538416..0000000 --- a/gradle.Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -ARG JDK_VERSION=11 -ARG GRADLE_VERSION=7.1 - -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 - diff --git a/todo.txt b/todo.txt deleted file mode 100644 index e940649..0000000 --- a/todo.txt +++ /dev/null @@ -1,15 +0,0 @@ -== Icônes pour recettes non-approuvés / quantité faible == -== Texte SIMDUT inexistant (fiche signalitique) pour les matériaux == - - - -== Comptes == -No employé - Permissions - Employés - - - -== Kits de retouche == -No Job - No Dossier - Qté - Description - Case à cocher - Note - Bouton compléter si tout est coché/imprimé ? - -Enregistrer localdatetime/personne pendant une certaine durée