This repository contains a Spring Boot REST API project that is integrated with GitLabCI for Continuous Integration and Continuous Deployment.
The repository (https://gitlab.com/adnanedrief/gitlab-ci-rest-api-springboot) contains the source code for the REST API and a Dockerfile to package the application as a Docker image.
- Java 17
- Maven
- Docker
- GitLab account
The pipeline consists of two stages: build and deploy.
In the build stage, the code is compiled using Maven and a JAR file is produced as an artifact.
In the deploy stage, the Docker image is built and pushed to the GitLab Container Registry.
-
The .gitlab-ci.yml file contains the configuration for the pipeline. The configuration file defines the different stages in the pipeline, the jobs to be executed in each stage, and the Docker images to be used for each job.
-
The build job is responsible for compiling the code and generating the jar file. The deploy job is responsible for building the Docker image and pushing it to GitLab.
-
The pipeline uses two Docker images: maven:latest for the build job and docker:latest for the deploy job. The docker:dind service is used to enable Docker inside the Docker container used by the deploy job.
-
The artifacts produced by the build job are stored in the target directory, which is defined in the artifacts section of the job. The deploy job retrieves the jar file from the artifacts and uses it to build the Docker image.