A simple spring boot application that provides an API endpoint for listing books.
| Technology | Version | Description |
|---|---|---|
| JAVA | 21 | backend programming language |
| Spring boot | 3.4.1 | backend framework |
| MongoDB | 8.0 | NoSQL document database |
| Docker (Engine) | 27.2.1 | Containerisation |
| Kubernetes (k8s) | Container orchestration | |
| Kubectl | v1.27.3 (server) & v1.31.4 (client) | Command line tool for interacting with kubernetes APIs |
| Minikube | v1.31.1 | allow running single-node kubernetes cluster on personal computer for development and testing |
The following instructions outline how to manually build and push the docker image to GitHub Container registry.
N/B: The automatic way of achieving the same is outlined in the CI/CD section.
docker build --tag ghcr.io/<your-github-username>/kyosk-test:v1 .Please check here for information on where to get the password.
docker login ghcr.io --username <your-github-username> --password-stdindocker image push ghcr.io/<your-github-username>/kyosk-test:v1The following command assumes:
- ports 27017 and 8081 are not in use.
- the command is running on a Unix-based system.
The application has Spring boot docker compose integration for faster development. Mongo DB will automatically be pulled and started before the application is fully started.
./gradlew bootRunPlease check the k8s directory for the kubernetes manifest (.yaml files).
minikube startThe following command assumes that Start minikube phase is done successfully.
kubectl apply --filename k8s/The following command assumes that Apply k8s manifests phase is done successfully.
N/B: this is optional, but can be helpful in debugging when things are not working as expected.
kubectl get allThis assumes port 8080 is not in use.
kubectl port-forward services/kyosk-backend 8080:8080- Open your favorite web browser.
- Visit
http://localhost:8080/booksin a new browser tab.
Show a list of prepopulated books.
curl --request "GET" \
--header "Accept: application/json" \
--url 'http://localhost:8080/books'Continuous Integration (CI) & Continuous Deployment (CD) pipeline is running on GitHub Actions.
When changes have been pushed to the main branch or pull request is open to the main branch, the CI job is run.
In the CI phase,
- the repository is first checked out (cloned locally).
- the mongo db versions (7 & 8) are set up and started. This will be used later.
- Java version 21 from the temurin distribution is set up. Our application being a java application, will need it for the subsequent steps.
- Gradle is configured for optimal use of GitHub Actions resources through caching of downloaded dependencies.
- Build the application using the Gradle wrapper script to ensure everything in terms of application configuration is in order.
- Run the automated tests included in the application using the Gradle wrapper script to ensure all the components are in working order.
When a new release tag with the pattern v*.*.* is pushed, the CD job is run.
But before the CD phase is run, the CI phase must run successfully to ensure we do not deploy broken docker images.
A new release tag can be cut as follows:
git tag --annotate v1.0.0 --message "Version 1.0.0"and pushed to GitHub as follows:
git push --tagsThis will automatically trigger the docker image building and pushing to GitHub container registry upon successful execution of the CI job.
We've chosen GitHub Container Registry to avoid managing separate authentication secrets for our container registry. Since our code, CI/CD pipelines, and container images all reside on GitHub, authentication is handled seamlessly within the platform.



