Skip to content

Commit

Permalink
Merge pull request #1 from companieshouse/initial-skeleton-branch
Browse files Browse the repository at this point in the history
✨  initial commit
  • Loading branch information
aaspellclark-ch authored Feb 5, 2025
2 parents 8acad64 + 1c53fe8 commit 5dcad0e
Show file tree
Hide file tree
Showing 33 changed files with 1,335 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
/suppress.xml
target
.idea
51 changes: 51 additions & 0 deletions HELP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Read Me First
The following was discovered as part of building this project:

* No Docker Compose services found. As of now, the application won't start! Please add at least one service to the `compose.yaml` file.

# Getting Started

### Reference Documentation
For further reference, please consider the following sections:

* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/3.4.2/maven-plugin)
* [Create an OCI image](https://docs.spring.io/spring-boot/3.4.2/maven-plugin/build-image.html)
* [Spring Boot Testcontainers support](https://docs.spring.io/spring-boot/3.4.2/reference/testing/testcontainers.html#testing.testcontainers)
* [Testcontainers Kafka Modules Reference Guide](https://java.testcontainers.org/modules/kafka/)
* [Spring for Apache Kafka](https://docs.spring.io/spring-boot/3.4.2/reference/messaging/kafka.html)
* [Docker Compose Support](https://docs.spring.io/spring-boot/3.4.2/reference/features/dev-services.html#features.dev-services.docker-compose)
* [Spring Security](https://docs.spring.io/spring-boot/3.4.2/reference/web/spring-security.html)
* [Testcontainers](https://java.testcontainers.org/)

### Guides
The following guides illustrate how to use some features concretely:

* [Securing a Web Application](https://spring.io/guides/gs/securing-web/)
* [Spring Boot and OAuth2](https://spring.io/guides/tutorials/spring-boot-oauth2/)
* [Authenticating a User with LDAP](https://spring.io/guides/gs/authenticating-ldap/)

### Docker Compose support
This project contains a Docker Compose file named `compose.yaml`.

However, no services were found. As of now, the application won't start!

Please make sure to add at least one service in the `compose.yaml` file.

### Testcontainers support

This project uses [Testcontainers at development time](https://docs.spring.io/spring-boot/3.4.2/reference/features/dev-services.html#features.dev-services.testcontainers).

Testcontainers has been configured to use the following Docker images:

* [`apache/kafka-native:latest`](https://hub.docker.com/r/apache/kafka-native)

Please review the tags of the used images and set them to the same as you're running in production.

### Maven Parent overrides

Due to Maven's design, elements are inherited from the parent POM to the project POM.
While most of the inheritance is fine, it also inherits unwanted elements like `<license>` and `<developers>` from the parent.
To prevent this, the project POM contains empty overrides for these elements.
If you manually switch to a different parent and actually want the inheritance, you need to remove those overrides.

62 changes: 62 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
artifact_name := chs-notification-sender-api
version := "unversioned"

.PHONY: all
all: build

.PHONY: clean
clean:
mvn clean
rm -f ./$(artifact_name).jar
rm -f ./$(artifact_name)-*.zip
rm -rf ./build-*
rm -f ./build.log

.PHONY: security-check
security-check:
mvn org.owasp:dependency-check-maven:update-only
mvn org.owasp:dependency-check-maven:check -DfailBuildOnCVSS=4 -DassemblyAnalyzerEnabled=false

.PHONY: build
build:
mvn versions:set -DnewVersion=$(version) -DgenerateBackupPoms=false
mvn package -DskipTests=true
cp ./target/$(artifact_name)-$(version).jar ./$(artifact_name).jar

.PHONY: test
test: clean
mvn verify

.PHONY: test-unit
test-unit: clean
mvn test -DexcludedGroups="integration-test"

.PHONY: test-integration
test-integration: clean
mvn test -Dgroups="integration-test"

.PHONY: package
package:
ifndef version
$(error No version given. Aborting)
endif
$(info Packaging version: $(version))
mvn versions:set -DnewVersion=$(version) -DgenerateBackupPoms=false
mvn package -DskipTests=true
$(eval tmpdir:=$(shell mktemp -d build-XXXXXXXXXX))
cp ./start.sh $(tmpdir)
cp ./routes.yaml $(tmpdir)
cp ./target/$(artifact_name)-$(version).jar $(tmpdir)/$(artifact_name).jar
cd $(tmpdir); zip -r ../$(artifact_name)-$(version).zip *
rm -rf $(tmpdir)

.PHONY: dist
dist: clean build package

.PHONY: sonar
sonar:
mvn sonar:sonar

.PHONY: sonar-pr-analysis
sonar-pr-analysis:
mvn sonar:sonar -P sonar-pr-analysis
17 changes: 17 additions & 0 deletions Tiltfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local_resource(
name = 'dev:chs-notification-sender-api',
cmd = 'mvn clean compile',
deps = ['src']
)
custom_build(
ref = '416670754337.dkr.ecr.eu-west-2.amazonaws.com/chs-notification-sender-api:latest',
command = 'mvn clean compile jib:dockerBuild -Dimage=$EXPECTED_REF',
live_update = [
sync(
local_path = './target/classes',
remote_path = '/app/classes'
),
restart_container()
],
deps = ['./target/classes']
)
8 changes: 8 additions & 0 deletions ecs-image-build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ARG IMAGE_VERSION="latest"
FROM 416670754337.dkr.ecr.eu-west-2.amazonaws.com/ci-corretto-runtime-21:${IMAGE_VERSION}

WORKDIR /opt
COPY /app .
COPY docker_start.sh .

CMD ["./docker_start.sh"]
7 changes: 7 additions & 0 deletions ecs-image-build/docker_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
#
# Start script for accounts-association-service

PORT=8080

exec java -jar -Dserver.port="${PORT}" "chs-notification-sender-api.jar"
Loading

0 comments on commit 5dcad0e

Please sign in to comment.