Lab 1 Report
Link to the CI/CD job of the executed game
https://gitlab.stud.atlantis.ugent.be/fabianehis/devops-project/-/jobs/247999
Structure of the .gitlab-ci.yml
Base image
At the start of the file i define a base image.
image: gitlab.stud.atlantis.ugent.be:5050/utils/docker/eclipse-temurin:25-jdk
Variables
Then i define variables that i'll need for generating my maven-container image
variables:
MAVEN_CLI_OPTS: "--batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
QUARKUS_CONTAINER_IMAGE_PUSH: true
QUARKUS_CONTAINER_IMAGE_USERNAME: $CI_REGISTRY_USER
QUARKUS_CONTAINER_IMAGE_PASSWORD: $CI_REGISTRY_PASSWORD
QUARKUS_CONTAINER_IMAGE_REGISTRY: $CI_REGISTRY
QUARKUS_CONTAINER_IMAGE_GROUP: $CI_PROJECT_PATH
QUARKUS_CONTAINER_IMAGE_TAG: latest
Stages
Lastly, i define and declare the stages that need to be executed.
stages:
- build
- package
- execute
maven-build:
stage: build
script:
- ./mvnw $MAVEN_CLI_OPTS compile
artifacts:
paths:
- target/*
cache:
key: dependencies-cache
paths:
- .m2/repository
maven-container-image-generation:
stage: package
script:
- printenv
- echo $QUARKUS_CONTAINER_IMAGE_REGISTRY/$QUARKUS_CONTAINER_IMAGE_GROUP/logic-service:$QUARKUS_CONTAINER_IMAGE_TAG
- ./mvnw verify -Dquarkus.container-image.build=true
- ./mvnw install -Dquarkus.container-image.push=true
run-game:
stage: execute
variables:
PLAYER_NAME: "Fabian"
LOGIC_URL: http://logic-service:8080
TURN_INTERVAL_MS: 25
TURN_LIMIT: 100
image:
name: gitlab.stud.atlantis.ugent.be:5050/utils/docker/devops-runner:latest
entrypoint:
- ""
services:
- name: $QUARKUS_CONTAINER_IMAGE_REGISTRY/$QUARKUS_CONTAINER_IMAGE_GROUP/logic-service:$QUARKUS_CONTAINER_IMAGE_TAG
alias: logic-service
script:
- java -cp /app/resources:/app/classes:/app/libs/* be.ugent.devops.gamehost.services.runner.LauncherKt
Answered Questions
What is ./mvnw and what is the advantage of using it above mvn?
./mvnw is a wrapper script that downloads a version from Maven that is compatible with your project. The advantage of using it is that it gives the ability to collaborate with other developers. It also downloads maven for us, so we don't have to do it.
Explain the key differences between GitLab's cache and artifacts mechanisms. For each of Maven dependencies and build files, explain which mechanism you chose and why. What are the trade-offs of your choices?
The difference between a cache and a artifact is that a cache stores files such that it can be used across different pipelines and different jobs. On the otherhand a artifact stores files for one pipeline which can be used for different jobs.
To store the dependencies i used a cache, because many projects may have the same dependencies and to download them in their respective pipelines may take a bunch time. For builds i used a artifact because build files are unique to a project so their wouldn't be a need to used such files across pipelines for different projects.
The trade-offs for cache:
- If dependencies change but cache key stays the same, you may get stale or inconsistent builds.
- Large caches can slow jobs when downloading/uploading The trade-offs for artifact:
- Every pipeline keeps its artifacts until they expire, thus it can fill up the GitLab storage quickly.
- GitLab must upload and download artifacts between stages, large files slow this down.
In this lab, we use a 25-jre image as the base for our runtime container and a 25-jdk image for the CI/CD build jobs. Explain the reasoning behind this choice. What would be the impact (positive or negative) of using 25-jdk for both? What about using 25-jre for both?
Using 25-jdk voor both situations causes the pipeline to slow down, because it needs download all the tools that comes with JDK. With 25-jre only the minimal tools are being downloaded which makes the pipeline faster.