This project contains source code and supports files for a containerized application that you can deploy with the Copilot CLI. It includes the following files and folders.
- src/main - Code for the container application.
- src/test - Integration tests for the application code.
- src/main/resources - Spring Boot configuration files.
This application manages Quartz Jobs with the help of Spring Webflux and Spring Native.
If you want to use tha Spring Boot Native version of the Tasks API service, you need to update the compose.yaml
file
and change the apis/city-tasks-api/Dockerfile
property value to apis/city-tasks-api/Dockerfile
in the tasks-api
service.
IMPORTANT: The GraalVM native-image
compiler should be installed and configured on your machine.
If you're experiencing JMV memory issues, execute the following commands to increase the JVM memory and execute Maven with more CPU cores:
export _JAVA_OPTIONS="-Xmx8g -Xms4g"
mvn -T 4C clean native:compile -Pnative -DskipTests -f apis/city-tasks-api/pom.xml -Ddependency-check.skip=true
Use the Hiperium Login command to authenticate with your AWS IAM Identity Center with the name of your IdP profile:
hiperium-login
Then, execute the main a shell script selecting option 1. Docker Compose.
to build and deploy the project locally using Docker Compose.
./run-scripts.sh
Open a new terminal tab and edit your /etc/hosts
file adding a new entry point to access the API service using HTTPS:
vim /etc/hosts
Add the following line and save the file:
127.0.0.1 dev.hiperium.cloud
Open your Postman and import the collection Hiperium.postman_collection.json
to test the API endpoints.
First, add a new Quartz Job using the POST /api/v1/jobs
endpoint and then, execute the POST /api/v1/tasks
endpoint using a near execution date time.
Notice when the Task is executed by the Quartz Scheduler, you must see the logs in the docker-compose terminal window.
You can also run your existing tests suite in a native image. This is an efficient way to validate the compatibility of your application:
mvn -T 2C test -PnativeTest -f apis/city-tasks-api/pom.xml
If you're already familiar with Spring Boot container images support, this is the easiest way to get started. Docker should be installed and configured on your machine prior to creating the image.
To create the image, run the following goal:
$ mvn spring-boot:build-image -Pnative -DskipTests
Then, you can run the app like any other container:
$ docker run --rm city-tasks-api:1.8.0
Use this option if you want to explore more options such as running your tests in a native image.
The GraalVM native-image
compiler should be installed and configured on your machine.
NOTE: GraalVM 22.3+ is required.
To create the executable, run the following goal:
$ mvn native:compile -Pnative -DskipTests
Then, you can run the app as follows:
$ target/city-tasks-api
Execute the following command:
awslocal dynamodb scan --table-name Devices
- List all of your AWS Copilot applications.
copilot app ls
- Show information about the environments and services in your application.
copilot app show
- Show information about your environments.
copilot env ls
- List of all the services in an application.
copilot svc ls
- Show service status.
copilot svc status
- Show information about the service, including endpoints, capacity and related resources.
copilot svc show
- Show logs of a deployed service.
export AWS_PROFILE=tasks-dep-dev
copilot svc logs \
--app city-tasks \
--name api \
--env dev \
--since 1h \
--follow
- Start an interactive bash session with a task part of the service:
copilot svc exec \
--app city-tasks \
--name api \
--env dev
- Delete and clean-up all created resources.
copilot app delete --yes
For further reference, please consider the following sections:
- Official Apache Maven documentation
- Spring Boot Maven Plugin Reference Guide
- Create an OCI image
- GraalVM Native Image Support
- Spring Reactive Web
- Testcontainers
- Testcontainers Postgres Module Reference Guide
- OAuth2 Authorization Server
- OAuth2 Resource Server
- Spring Data JPA
- Flyway Migration
- Quartz Scheduler
- Validation
- Spring Boot Actuator
The following guides illustrate how to use some features concretely:
- Building a Reactive RESTful Web Service
- Accessing Data with JPA
- Validation
- Building a RESTful Web Service with Spring Boot Actuator
These additional references should also help you: