A template project which creates a service using spring boot. This is based on spring-boot-java-base by bnc-projects.
We follow Semantic Versioning. The major and minor version can be updated in the build.gradle
file at the root of the project.
Due to the highly automated deployment pipelines, it is up to developers when they increment version numbers based on the semver rules.
This project uses gradle and the default tasks to compile and run tests.
./gradlew clean check assemble
- Build the docker container
./gradlew clean check assemble docker
- Run the docker container
docker run -e SPRING_PROFILES_ACTIVE=localhost -p 8080:8080 -i -t spring-boot-service
./gradlew clean assemble check docker dockerTag
To debug the container locally, the JAVA_OPTS
environment variable can be provided when running
the container.
docker run -p 8080:8080 -i -t -e JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005" spring-boot-service
To set up the project by forking this project, then the following instructions need to be carried out. Please read these instructions carefully to ensure no steps are missed out.
For code quality checks we use SonarCloud and the project must be setup in SonarCloud.
- Login to SonarCloud
- Click the + and then Analyze new project
- Select the GitHub project you have created with this template
- Click Setup
- The following files need to be modified to suit your project.
- Update the links to the badges
- Update all references for spring-boot-service
- Update
rootProject.name
to be the correct project name. E.g: foo
- Update the packages to suit your service.
- Update/Remove dummy classes, methods and tests.
- Update the application name in the spring configuration to suit your service.
- Application configuration and secrets are stored in AWS Parameter store or AWS secrets manager
- Configuration can be set globally for all services or overridden/set per service.
We follow semantic versioning where possible. Generally we do not update versions unless there has been a breaking change in our service contracts.
The versions can be increased in the GitHub Action file when required.
This project uses Terraform to deploy the service to the PreviewMe ECS cluster.
The ECR and Service deployment require AWS Credentials to be setup in Terraform Cloud. This can be done by running the terraform-cloud-boostrap action.
The following changes need to be made in the Terraform configuration.
The GitHub workflow will use the repository name for the application name, it is essential to name the repository appropriately. E.g: foo-service.
deployment/ecr/backend.tf
replace the workspace name to match the project name in settings.gradle. E.g: foo-ecrdeployment/service/backend.tf
replace the workspace prefix to match the project name in settings.gradle. E.g: foo-service
To ensure the service deploys correctly the following steps need to be carried out:
- Update the
application_name
andapplication_path
in `deployment/service/variables.tf - Enable production deployments by replacing
if: ${{ false }}
withif: github.ref == 'refs/heads/main' && github.event_name == 'push'