From 13814ec4b6eea050f1189e5f2064b086316cc052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <xpokorn8@fi.muni.cz> Date: Thu, 6 Apr 2023 13:28:12 +0200 Subject: [PATCH 01/11] Extended pipeline to deploy to Docker --- application/Dockerfile | 3 +++ application/pipeline.yml | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 application/Dockerfile diff --git a/application/Dockerfile b/application/Dockerfile new file mode 100644 index 00000000..4b568892 --- /dev/null +++ b/application/Dockerfile @@ -0,0 +1,3 @@ +FROM docker.io/library/eclipse-temurin:17-jre-focal +COPY module-language-school/target/module-language-school-0.0.1-SNAPSHOT.jar /app.jar +ENTRYPOINT ["java", "-jar", "/app.jar"] diff --git a/application/pipeline.yml b/application/pipeline.yml index 2b29b6dd..167aa0ef 100644 --- a/application/pipeline.yml +++ b/application/pipeline.yml @@ -1,27 +1,54 @@ # This file specifies GitLab CI/CD pipeline, see https://docs.gitlab.com/ee/ci/ stages: + - build - test + - deploy variables: # variable read by Maven for JVM options, see https://maven.apache.org/configure.html#maven_opts-environment-variable MAVEN_OPTS: " -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository " # our own variable for repeated options MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version " + # docker image repository and tag + DOCKER_IMAGE: "xpokorn8/sprachschulsystem" + DOCKER_TAG: "M1" + +# name of Docker image in which the script commands are executed +image: maven:latest + + +build: + stage: build + tags: + - shared-fi + image: maven:latest + script: + - 'cd "$CI_PROJECT_DIR/application"' + - 'mvn $MAVEN_CLI_OPTS clean install -DskipTests' test: stage: test tags: - shared-fi - # name of Docker image in which the script commands are executed image: maven:latest - # script is a list of linux shell commands script: - # run maven build - 'cd "$CI_PROJECT_DIR/application"' - - 'mvn $MAVEN_CLI_OPTS clean install' + - 'mvn $MAVEN_CLI_OPTS test' cache: - # caches maven repo between runs paths: - .m2/repository +deploy: + when: manual + stage: deploy + cache: + paths: + - .m2/repository + script: + - 'cd "$CI_PROJECT_DIR/application"' + - 'mvn $MAVEN_CLI_OPTS install -DskipTests' + - 'podman build -t $DOCKER_IMAGE:$DOCKER_TAG .' + - 'podman save --quiet -o sprachschulsystem.tar $DOCKER_IMAGE:$DOCKER_TAG' + - 'docker login -u $DOCKER_PRIVATE_LOGIN -p $DOCKER_PRIVATE_PASSWORD' + - 'podman push $DOCKER_IMAGE:$DOCKER_TAG' -- GitLab From 41b5f76904e2ec2e9335bf0d5bf74a6b2d4da95a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <xpokorn8@fi.muni.cz> Date: Fri, 7 Apr 2023 08:48:22 +0200 Subject: [PATCH 02/11] Delegated docker things to gitlab --- application/pipeline.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/application/pipeline.yml b/application/pipeline.yml index 167aa0ef..bd0280ee 100644 --- a/application/pipeline.yml +++ b/application/pipeline.yml @@ -11,8 +11,6 @@ variables: # our own variable for repeated options MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version " # docker image repository and tag - DOCKER_IMAGE: "xpokorn8/sprachschulsystem" - DOCKER_TAG: "M1" # name of Docker image in which the script commands are executed image: maven:latest @@ -42,12 +40,9 @@ test: deploy: when: manual stage: deploy - cache: - paths: - - .m2/repository script: - 'cd "$CI_PROJECT_DIR/application"' - - 'mvn $MAVEN_CLI_OPTS install -DskipTests' + - 'mvn $MAVEN_CLI_OPTS install package -DskipTests' - 'podman build -t $DOCKER_IMAGE:$DOCKER_TAG .' - 'podman save --quiet -o sprachschulsystem.tar $DOCKER_IMAGE:$DOCKER_TAG' - 'docker login -u $DOCKER_PRIVATE_LOGIN -p $DOCKER_PRIVATE_PASSWORD' -- GitLab From 0d2bb0e99b9bcec6886713237859014ea8546735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <xpokorn8@fi.muni.cz> Date: Fri, 7 Apr 2023 12:36:58 +0200 Subject: [PATCH 03/11] extended testing in pipeline --- application/pipeline.yml | 41 +++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/application/pipeline.yml b/application/pipeline.yml index bd0280ee..288f2a02 100644 --- a/application/pipeline.yml +++ b/application/pipeline.yml @@ -15,6 +15,9 @@ variables: # name of Docker image in which the script commands are executed image: maven:latest +cache: + paths: + - .m2/repository build: stage: build @@ -25,17 +28,41 @@ build: - 'cd "$CI_PROJECT_DIR/application"' - 'mvn $MAVEN_CLI_OPTS clean install -DskipTests' -test: +test-certificate: stage: test tags: - shared-fi image: maven:latest script: - - 'cd "$CI_PROJECT_DIR/application"' + - 'cd "$CI_PROJECT_DIR/application/module-certificate"' + - 'mvn $MAVEN_CLI_OPTS test' + +test-exercise: + stage: test + tags: + - shared-fi + image: maven:latest + script: + - 'cd "$CI_PROJECT_DIR/application/module-exercise"' + - 'mvn $MAVEN_CLI_OPTS test' + +test-language-school: + stage: test + tags: + - shared-fi + image: maven:latest + script: + - 'cd "$CI_PROJECT_DIR/application/module-language-school"' + - 'mvn $MAVEN_CLI_OPTS test' + +test-mail: + stage: test + tags: + - shared-fi + image: maven:latest + script: + - 'cd "$CI_PROJECT_DIR/application/module-mail"' - 'mvn $MAVEN_CLI_OPTS test' - cache: - paths: - - .m2/repository deploy: when: manual @@ -43,6 +70,10 @@ deploy: script: - 'cd "$CI_PROJECT_DIR/application"' - 'mvn $MAVEN_CLI_OPTS install package -DskipTests' + - 'cd service1 && docker build -t service1 .' + - 'cd ../service2 && docker build -t service2 .' + - 'cd ../service3 && docker build -t service3 .' + - 'cd ../service4 && docker build -t service4 .' - 'podman build -t $DOCKER_IMAGE:$DOCKER_TAG .' - 'podman save --quiet -o sprachschulsystem.tar $DOCKER_IMAGE:$DOCKER_TAG' - 'docker login -u $DOCKER_PRIVATE_LOGIN -p $DOCKER_PRIVATE_PASSWORD' -- GitLab From 72afc33904cef8e7fb15dc70bfb97f76795d7cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <xpokorn8@fi.muni.cz> Date: Fri, 7 Apr 2023 13:46:00 +0200 Subject: [PATCH 04/11] Update pipeline.yml --- application/pipeline.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/application/pipeline.yml b/application/pipeline.yml index 288f2a02..96d76c24 100644 --- a/application/pipeline.yml +++ b/application/pipeline.yml @@ -34,7 +34,9 @@ test-certificate: - shared-fi image: maven:latest script: - - 'cd "$CI_PROJECT_DIR/application/module-certificate"' + - 'cd "$CI_PROJECT_DIR/application"' + - 'mvn $MAVEN_CLI_OPTS clean install -DskipTests' + - 'cd "module-certificate"' - 'mvn $MAVEN_CLI_OPTS test' test-exercise: @@ -43,7 +45,9 @@ test-exercise: - shared-fi image: maven:latest script: - - 'cd "$CI_PROJECT_DIR/application/module-exercise"' + - 'cd "$CI_PROJECT_DIR/application"' + - 'mvn $MAVEN_CLI_OPTS clean install -DskipTests' + - 'cd "module-exercise"' - 'mvn $MAVEN_CLI_OPTS test' test-language-school: @@ -52,7 +56,9 @@ test-language-school: - shared-fi image: maven:latest script: - - 'cd "$CI_PROJECT_DIR/application/module-language-school"' + - 'cd "$CI_PROJECT_DIR/application"' + - 'mvn $MAVEN_CLI_OPTS clean install -DskipTests' + - 'cd "module-language-school"' - 'mvn $MAVEN_CLI_OPTS test' test-mail: @@ -61,7 +67,9 @@ test-mail: - shared-fi image: maven:latest script: - - 'cd "$CI_PROJECT_DIR/application/module-mail"' + - 'cd "$CI_PROJECT_DIR/application"' + - 'mvn $MAVEN_CLI_OPTS clean install -DskipTests' + - 'cd "module-mail"' - 'mvn $MAVEN_CLI_OPTS test' deploy: -- GitLab From 1ae7a48629225b96a507cbfbd14c962fba584b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <xpokorn8@fi.muni.cz> Date: Sat, 8 Apr 2023 01:23:44 +0200 Subject: [PATCH 05/11] added dockerfiles --- application/{ => module-certificate}/Dockerfile | 2 +- application/module-exercise/Dockerfile | 3 +++ application/module-language-school/Dockerfile | 3 +++ application/module-mail/Dockerfile | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) rename application/{ => module-certificate}/Dockerfile (51%) create mode 100644 application/module-exercise/Dockerfile create mode 100644 application/module-language-school/Dockerfile create mode 100644 application/module-mail/Dockerfile diff --git a/application/Dockerfile b/application/module-certificate/Dockerfile similarity index 51% rename from application/Dockerfile rename to application/module-certificate/Dockerfile index 4b568892..21e346d9 100644 --- a/application/Dockerfile +++ b/application/module-certificate/Dockerfile @@ -1,3 +1,3 @@ FROM docker.io/library/eclipse-temurin:17-jre-focal -COPY module-language-school/target/module-language-school-0.0.1-SNAPSHOT.jar /app.jar +COPY ./target/module-certificate-0.0.1-SNAPSHOT.jar /app.jar ENTRYPOINT ["java", "-jar", "/app.jar"] diff --git a/application/module-exercise/Dockerfile b/application/module-exercise/Dockerfile new file mode 100644 index 00000000..8e31eb6c --- /dev/null +++ b/application/module-exercise/Dockerfile @@ -0,0 +1,3 @@ +FROM docker.io/library/eclipse-temurin:17-jre-focal +COPY ./target/module-exercise-0.0.1-SNAPSHOT.jar /app.jar +ENTRYPOINT ["java", "-jar", "/app.jar"] diff --git a/application/module-language-school/Dockerfile b/application/module-language-school/Dockerfile new file mode 100644 index 00000000..f2be765c --- /dev/null +++ b/application/module-language-school/Dockerfile @@ -0,0 +1,3 @@ +FROM docker.io/library/eclipse-temurin:17-jre-focal +COPY ./target/module-language-school-0.0.1-SNAPSHOT.jar /app.jar +ENTRYPOINT ["java", "-jar", "/app.jar"] diff --git a/application/module-mail/Dockerfile b/application/module-mail/Dockerfile new file mode 100644 index 00000000..2e3cde27 --- /dev/null +++ b/application/module-mail/Dockerfile @@ -0,0 +1,3 @@ +FROM docker.io/library/eclipse-temurin:17-jre-focal +COPY ./target/module-mail-0.0.1-SNAPSHOT.jar /app.jar +ENTRYPOINT ["java", "-jar", "/app.jar"] -- GitLab From 66c72b815e8cf367ca6ed8ce1b64fa7fbe504da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <xpokorn8@fi.muni.cz> Date: Sat, 8 Apr 2023 01:26:06 +0200 Subject: [PATCH 06/11] added docker-compose.yml --- application/docker-compose.yml | 30 ++++++++++++++++++++++++++++++ application/podman-compose.yml | 30 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 application/docker-compose.yml create mode 100644 application/podman-compose.yml diff --git a/application/docker-compose.yml b/application/docker-compose.yml new file mode 100644 index 00000000..41a6a0d3 --- /dev/null +++ b/application/docker-compose.yml @@ -0,0 +1,30 @@ +version: '3' + +services: + certificate: + build: ./module-certificate + container_name: certificate + image: xpokorn8/sprachschulsystem:certificate + ports: + - "5001:5001" + + exercise: + build: ./module-exercise + container_name: exercise + image: xpokorn8/sprachschulsystem:exercise + ports: + - "5002:5002" + + language-school: + build: ./module-language-school + container_name: language-school + image: xpokorn8/sprachschulsystem:language-school + ports: + - "5000:5000" + + mail: + build: ./module-mail + container_name: mail + image: xpokorn8/sprachschulsystem:mail + ports: + - "5003:5003" \ No newline at end of file diff --git a/application/podman-compose.yml b/application/podman-compose.yml new file mode 100644 index 00000000..41a6a0d3 --- /dev/null +++ b/application/podman-compose.yml @@ -0,0 +1,30 @@ +version: '3' + +services: + certificate: + build: ./module-certificate + container_name: certificate + image: xpokorn8/sprachschulsystem:certificate + ports: + - "5001:5001" + + exercise: + build: ./module-exercise + container_name: exercise + image: xpokorn8/sprachschulsystem:exercise + ports: + - "5002:5002" + + language-school: + build: ./module-language-school + container_name: language-school + image: xpokorn8/sprachschulsystem:language-school + ports: + - "5000:5000" + + mail: + build: ./module-mail + container_name: mail + image: xpokorn8/sprachschulsystem:mail + ports: + - "5003:5003" \ No newline at end of file -- GitLab From 2064245896ef460484ab2fcdb9c44761c944eba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <xpokorn8@fi.muni.cz> Date: Sat, 8 Apr 2023 01:30:09 +0200 Subject: [PATCH 07/11] modded pipeline to run docker-compose --- application/pipeline.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/application/pipeline.yml b/application/pipeline.yml index 288f2a02..e07b16d2 100644 --- a/application/pipeline.yml +++ b/application/pipeline.yml @@ -69,12 +69,7 @@ deploy: stage: deploy script: - 'cd "$CI_PROJECT_DIR/application"' - - 'mvn $MAVEN_CLI_OPTS install package -DskipTests' - - 'cd service1 && docker build -t service1 .' - - 'cd ../service2 && docker build -t service2 .' - - 'cd ../service3 && docker build -t service3 .' - - 'cd ../service4 && docker build -t service4 .' - - 'podman build -t $DOCKER_IMAGE:$DOCKER_TAG .' - - 'podman save --quiet -o sprachschulsystem.tar $DOCKER_IMAGE:$DOCKER_TAG' + - 'mvn $MAVEN_CLI_OPTS install -DskipTests' + - 'docker-compose build --parallel' - 'docker login -u $DOCKER_PRIVATE_LOGIN -p $DOCKER_PRIVATE_PASSWORD' - - 'podman push $DOCKER_IMAGE:$DOCKER_TAG' + - 'docker-compose push' -- GitLab From 6eefd13d84030b924ba5e2f48a00147064fae800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <xpokorn8@fi.muni.cz> Date: Sat, 8 Apr 2023 01:41:48 +0200 Subject: [PATCH 08/11] added running tutorial to readme --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3a2ad124..17f5f20d 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,15 @@ - **Assigment**: - Create a system for language school lecture management. Each lecture can occur on a given day and time and is related to some course. The course is defined by its (unique) name, language and proficiency level. However, each lecture will be independent. That means that each lecture can have a different topic. Different lecturers can give it, and an arbitrary number of students can enrol. Each lecturer will have a name, surname, and record of taught languages. In addition, the lecturer will indicate that they are a native speaker. Exercises can be prepared for each course to allow the students to learn the language. Each student can pick the exercises depending on the levels of difficulty. -- **Running the modules**: +- **Running the modules using docker**: - ```cd ./application``` - - ```mvn clean install``` - - ```cd ./module-*``` - - ```mvn spring-boot:run``` + - ```docker-compose build --parallel``` + - ```docker-compose up``` + +- **Running the modules using podman**: + - ```cd ./application``` + - ```podman-compose build --parallel``` + - ```podman-compose up``` # Project Description -- GitLab From 18300a3b58293dec149dd76a7d063a32b3ff3549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <xpokorn8@fi.muni.cz> Date: Sat, 8 Apr 2023 10:50:44 +0200 Subject: [PATCH 09/11] modded pipeline --- application/pipeline.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/application/pipeline.yml b/application/pipeline.yml index e0b90f49..58a8f7ff 100644 --- a/application/pipeline.yml +++ b/application/pipeline.yml @@ -10,7 +10,6 @@ variables: MAVEN_OPTS: " -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository " # our own variable for repeated options MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version " - # docker image repository and tag # name of Docker image in which the script commands are executed image: maven:latest @@ -35,9 +34,7 @@ test-certificate: image: maven:latest script: - 'cd "$CI_PROJECT_DIR/application"' - - 'mvn $MAVEN_CLI_OPTS clean install -DskipTests' - - 'cd "module-certificate"' - - 'mvn $MAVEN_CLI_OPTS test' + - 'mvn $MAVEN_CLI_OPTS -am -pl module-certificate test' test-exercise: stage: test @@ -46,9 +43,7 @@ test-exercise: image: maven:latest script: - 'cd "$CI_PROJECT_DIR/application"' - - 'mvn $MAVEN_CLI_OPTS clean install -DskipTests' - - 'cd "module-exercise"' - - 'mvn $MAVEN_CLI_OPTS test' + - 'mvn $MAVEN_CLI_OPTS -am -pl module-exercise test' test-language-school: stage: test @@ -57,9 +52,7 @@ test-language-school: image: maven:latest script: - 'cd "$CI_PROJECT_DIR/application"' - - 'mvn $MAVEN_CLI_OPTS clean install -DskipTests' - - 'cd "module-language-school"' - - 'mvn $MAVEN_CLI_OPTS test' + - 'mvn $MAVEN_CLI_OPTS -am -pl module-language-school test' test-mail: stage: test @@ -68,9 +61,7 @@ test-mail: image: maven:latest script: - 'cd "$CI_PROJECT_DIR/application"' - - 'mvn $MAVEN_CLI_OPTS clean install -DskipTests' - - 'cd "module-mail"' - - 'mvn $MAVEN_CLI_OPTS test' + - 'mvn $MAVEN_CLI_OPTS -am -pl module-mail test' deploy: when: manual -- GitLab From 5cfbc1cd7e5707afb08ae26364896be4d43509f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <xpokorn8@fi.muni.cz> Date: Sat, 8 Apr 2023 11:47:15 +0200 Subject: [PATCH 10/11] Added description on how to run via docker --- README.md | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 17f5f20d..6f6bf5ca 100644 --- a/README.md +++ b/README.md @@ -11,18 +11,35 @@ - Martin Gargalovič *@xgargal* - Jan Pokorný *@xpokorn8* - Ester Vilímková - _Project Leader_ *@xvilimk* + + - **Assigment**: - Create a system for language school lecture management. Each lecture can occur on a given day and time and is related to some course. The course is defined by its (unique) name, language and proficiency level. However, each lecture will be independent. That means that each lecture can have a different topic. Different lecturers can give it, and an arbitrary number of students can enrol. Each lecturer will have a name, surname, and record of taught languages. In addition, the lecturer will indicate that they are a native speaker. Exercises can be prepared for each course to allow the students to learn the language. Each student can pick the exercises depending on the levels of difficulty. + +- **Running the modules using docker-compose**: + + ```console + cd ./application + docker-compose build --parallel + docker-compose up + ``` + +- **Running the modules using podman-compose**: + ~~~console + cd ./application + podman-compose build --parallel + podman-compose up + ~~~ + - **Running the modules using docker**: - - ```cd ./application``` - - ```docker-compose build --parallel``` - - ```docker-compose up``` - -- **Running the modules using podman**: - - ```cd ./application``` - - ```podman-compose build --parallel``` - - ```podman-compose up``` + ~~~console + sudo docker run -d -q -p 5001:5001 xpokorn8/sprachschulsystem:certificate && + sudo docker run -d -q -p 5002:5002 xpokorn8/sprachschulsystem:exercise && + sudo docker run -d -q -p 5000:5000 xpokorn8/sprachschulsystem:language-school && + sudo docker run -d -q -p 5003:5003 xpokorn8/sprachschulsystem:mail + ~~~ + # Project Description -- GitLab From 7d273ac0044d5f5e42325ce95e04e06ddffff388 Mon Sep 17 00:00:00 2001 From: evilimkova <xvilimk@fi.muni.cz> Date: Mon, 10 Apr 2023 13:51:11 +0200 Subject: [PATCH 11/11] Fixing Readme after testing --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6f6bf5ca..b1befef9 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ ```console cd ./application + mvn clean install docker-compose build --parallel docker-compose up ``` @@ -28,16 +29,17 @@ - **Running the modules using podman-compose**: ~~~console cd ./application + mvn clean install podman-compose build --parallel podman-compose up ~~~ - **Running the modules using docker**: ~~~console - sudo docker run -d -q -p 5001:5001 xpokorn8/sprachschulsystem:certificate && - sudo docker run -d -q -p 5002:5002 xpokorn8/sprachschulsystem:exercise && - sudo docker run -d -q -p 5000:5000 xpokorn8/sprachschulsystem:language-school && - sudo docker run -d -q -p 5003:5003 xpokorn8/sprachschulsystem:mail + sudo docker run -d -p 5001:5001 xpokorn8/sprachschulsystem:certificate && + sudo docker run -d -p 5002:5002 xpokorn8/sprachschulsystem:exercise && + sudo docker run -d -p 5000:5000 xpokorn8/sprachschulsystem:language-school && + sudo docker run -d -p 5003:5003 xpokorn8/sprachschulsystem:mail ~~~ -- GitLab