Skip to content

Commit

Permalink
[ESWE-1181] add SQS lib and localstack (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickchoijd authored Jan 15, 2025
1 parent 527f237 commit cbcd011
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ The integration service has a `/health` endpoint which indicates the service is
## Running the application locally

* Run with the Spring profile `dev` on local
* Set active profile via this environmental variable `spring.profiles.active=dev`
* Set active profile via this environmental variable `spring.profiles.active=dev` or `SPRING_PROFILES_ACTIVE=dev`
* Run with the Spring profile `local` group on local
* Set active profile to `local`: `spring.profiles.active=local` or `SPRING_PROFILES_ACTIVE=local`
* The `local` group will utilise `localstack` for Integration features with message queue (`SQS`)
* API Spec:
* Goto `http://localhost:8080/swagger-ui/index.html` to explore the OpenAPI specifications
* Checking endpoints
Expand All @@ -30,16 +33,19 @@ The integration service has a `/health` endpoint which indicates the service is
### Running with Docker

```bash
docker compose pull && docker compose up
docker compose pull && docker compose up -d
```

will build the application and run it and HMPPS Auth within a local docker instance.

### Running the application in Intellij

```bash
docker compose pull && docker compose up --scale hmpps-jobs-board-integration-api=0
docker compose pull && docker compose up --scale hmpps-jobs-board-integration-api=0 -d
```

will just start a docker instance of HMPPS Auth. The application should then be started with a `dev` active profile
will just start a docker instance of HMPPS Auth and `localstack`. The application should then be started with a `dev` or `local` active profile
in Intellij.
* supply required env var, e.g.
* `spring.profiles.active`=`dev`
* `SPRING_PROFILES_ACTIVE`=`local`
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ext["logback.version"] = "1.5.15"

dependencies {
implementation("uk.gov.justice.service.hmpps:hmpps-kotlin-spring-boot-starter:1.1.1")
implementation("uk.gov.justice.service.hmpps:hmpps-sqs-spring-boot-starter:5.2.2")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0")

Expand Down
15 changes: 14 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- HMPPS_AUTH_URL=http://hmpps-auth:8080/auth
# TODO: Remove this URL and replace with outgoing service URLs
- EXAMPLE_URL=http://hmpps-jobs-board-integration-api:8080
- SPRING_PROFILES_ACTIVE=dev
- SPRING_PROFILES_ACTIVE=dev,local

hmpps-auth:
image: quay.io/hmpps/hmpps-auth:latest
Expand All @@ -31,5 +31,18 @@ services:
- SPRING_PROFILES_ACTIVE=dev
- APPLICATION_AUTHENTICATION_UI_ALLOWLIST=0.0.0.0/0

localstack:
image: localstack/localstack:4
container_name: integration-localstack
ports:
- "4566:4566" # LocalStack Gateway
- "4510-4559:4510-4559" # external services port range
environment:
- SERVICES=sqs
- DEBUG=${DEBUG:-0}
volumes:
- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"

networks:
hmpps:
5 changes: 5 additions & 0 deletions src/main/resources/application-localstack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
hmpps.sqs:
provider: localstack
queues:
integrationqueue:
queueName: hmpps_jobs_board_integration_queue
5 changes: 5 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ spring:
authorization-grant-type: client_credentials
scope: read

profiles:
group:
local:
- "dev"
- "localstack"
server:
port: 8080
servlet:
Expand Down

0 comments on commit cbcd011

Please sign in to comment.