Lab 1 Report
latest commit: a97e22ef
report:
Report DevOps lab 1
Yaml file structure
all GitLab and other variables are declared above in the file. Searching for the right GitLab variables was confusing, and needed a lot of trail and error.
beneath that, a cache is declared to save all maven dependencies into. the key is shared between the build and install stages.
In the build stage, an artifact is created, which is then passed on to the install stage, where the result is used to install the image.
I had a lot of trouble trying to understand each step and with finding the right commands, making this entire lab a lot of trail and error. In the end, I think the result is satisfactory.
Questions
1) What is ./mvnw and what is the advantage of using it above mvn?
The mvnw make sure that every build has the right maven version. This is better for reproduction, with less setup. Perfect for a ci/cd pipeline.
2) 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?
Caches are shared files between jobs of the same pipeline. If certain jobs use said files, they don't have to be downloaded again. Subsequent runs of that same pipeline will reuse the cache. This makes all runs after the first faster.
Artifacts are saved files, libraries, etc. They are output from jobs that need to be passed to other jobs in the same pipeline. They are only used within the same run of a pipeline. Other runs will not use the artifacts of previous runs.
For the maven dependencies, I chose to use caches. All dependencies that were downloaded in the first job don't need to be downloaded again. As most of the time, these dependencies don't change to often, storing them in a cache that is shared over multiple runs seemed like a good idea.
For the output of the build job, I used a artifact. This because this result can be used in the install job. As the compilation result can change from run to run, keeping the result in an artifact that only is used within the same run also seemed like a goo idea.
3) 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?
THe 25 in both the JRE and JDK is the java version.
We use the JRE (java runtime environment) for the runtime jobs, as it has the ability to execute java programs. The JRE can not compile java code, but it does not need to in this container, it only needs to run the program. As the JRE can only run java programs, and doesn't have the libraries to compile, it is smaller than the JDK. So choosing the JRE image for the runtime container, keeps it smaller.
For the CI/CD build jobs, we need to choose the larger JDK image, as we need it to build the program.
Choosing the JDK for both would work, but the runtime container would be unnecessarily large, as it has no need for the included libraries.
Choosing the JRE for both on the other hand won't work, as the build jobs won't have the libraries necessary to build the java programs.