Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b5c8da0
Add Docker Compose sample for Doma Spring Boot (#291)
devin-ai-integration[bot] May 19, 2025
492079e
Fix code formatting issues
devin-ai-integration[bot] May 19, 2025
9a54fdc
Update Docker Compose sample to use Spring Boot's built-in Docker Com…
devin-ai-integration[bot] May 19, 2025
f8fca44
Fix code formatting issues
devin-ai-integration[bot] May 19, 2025
22218e7
Address PR feedback: Use Spring Boot Docker Compose support correctly
devin-ai-integration[bot] May 19, 2025
0c1d0e9
Address PR feedback: Remove duplicate properties and auto-detect dialect
devin-ai-integration[bot] May 19, 2025
54abc1d
Address PR feedback: Remove H2 dependency and update README
devin-ai-integration[bot] May 19, 2025
8d4b1e1
Remove openrewrite maven plugin from pom.xml
making May 19, 2025
b833b87
Add TestContainers sample for Doma Spring Boot (#310)
devin-ai-integration[bot] May 19, 2025
c2b2c05
Update Docker Compose sample to match TestContainers sample tests
devin-ai-integration[bot] May 19, 2025
bc628f6
Add schema-test.sql to reset database sequence for tests
devin-ai-integration[bot] May 19, 2025
8f69bac
Merge branch 'master' into devin/1747645402-add-docker-compose-sample
making May 19, 2025
ccbb570
Address PR feedback: Move sequence reset to test code, update logging…
devin-ai-integration[bot] May 19, 2025
0090fb5
Remove test application.properties as it's redundant with main applic…
devin-ai-integration[bot] May 19, 2025
b616f81
Add TestContainers fallback for Docker Compose sample in CI
devin-ai-integration[bot] May 19, 2025
bd35370
Format DockerComposeTestConfiguration.java
devin-ai-integration[bot] May 19, 2025
a68bdde
Revert "Format DockerComposeTestConfiguration.java"
making May 19, 2025
10064a2
Revert "Add TestContainers fallback for Docker Compose sample in CI"
making May 19, 2025
739caf8
update
making May 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Getting Started
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HELP.md should not be managed in git.
Add HELP.md into .gitignore


### 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.5/maven-plugin)
* [Create an OCI image](https://docs.spring.io/spring-boot/3.4.5/maven-plugin/build-image.html)
* [Docker Compose Support](https://docs.spring.io/spring-boot/3.4.5/reference/features/dev-services.html#features.dev-services.docker-compose)
* [Spring Web](https://docs.spring.io/spring-boot/3.4.5/reference/web/servlet.html)

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

* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)

### Docker Compose support
This project contains a Docker Compose file named `compose.yaml`.
In this file, the following services have been defined:

* postgres: [`postgres:latest`](https://hub.docker.com/_/postgres)

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.

Original file line number Diff line number Diff line change
@@ -1,58 +1,69 @@
# Doma Spring Boot Sample with Docker Compose

This sample demonstrates how to use Doma with Spring Boot using Docker Compose.
This sample demonstrates how to use Doma with Spring Boot's Docker Compose support.

## Requirements

- Docker
- Docker Compose

## How it works

This sample uses Spring Boot's built-in Docker Compose support, which automatically:

1. Detects the `compose.yaml` file in the project root
2. Starts the PostgreSQL container defined in the compose file
3. Configures the application to connect to the database

The `spring-boot-docker-compose` dependency enables this functionality, allowing the application to seamlessly integrate with Docker Compose services.

## Running the sample

From the sample directory, run:

```bash
docker compose up
./mvnw spring-boot:run
```

This will:
1. Start a PostgreSQL database container
2. Build the Spring Boot application
3. Start the application container linked to the database
Spring Boot will automatically:
- Start the PostgreSQL container defined in compose.yaml
- Configure the application to connect to the database
- Run the application

## Using the application

Once both containers are running, you can access the application at http://localhost:8080
Once the application is running, you can access it at http://localhost:8080

### API Endpoints

- `GET /` - List all messages
- `GET /?text=hello` - Add a new message with the text "hello"

## Running the application locally
## Configuration

If you want to run the application locally while using the Docker PostgreSQL database:
The PostgreSQL configuration is defined in the `compose.yaml` file:

1. Start only the database container:
```bash
docker compose up postgres
```
```yaml
services:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update README

postgres:
image: 'postgres:latest'
environment:
- 'POSTGRES_DB=${POSTGRES_DB}'
- 'POSTGRES_PASSWORD=${POSTGRES_PASSWORD}'
- 'POSTGRES_USER=${POSTGRES_USER}'
ports:
- '5432'
```

Before running the application, you should set the following environment variables:
- `POSTGRES_DB`: The name of the PostgreSQL database (e.g., "domadb")
- `POSTGRES_USER`: The PostgreSQL username (e.g., "doma")
- `POSTGRES_PASSWORD`: The PostgreSQL password

2. Run the application:
```bash
./mvnw spring-boot:run
```
Spring Boot automatically configures the application to connect to this database.

## Notes

- The PostgreSQL data is persisted in a Docker volume
- The application connects to PostgreSQL using environment variables with default values
- You can customize the database configuration by setting the following environment variables:
- `POSTGRES_DB`: Database name (default: domadb)
- `POSTGRES_USER`: Database username (default: doma)
- `POSTGRES_PASSWORD`: Database password (default: changeme)
- No manual configuration of database connection properties is needed
- The schema.sql file is automatically executed when the application starts

## Security Note

For production use, always set secure passwords through environment variables rather than using the defaults.
- Spring Boot manages the lifecycle of the Docker containers
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
postgres:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the generated compose.yaml as is

image: 'postgres:latest'
environment:
- 'POSTGRES_DB=${POSTGRES_DB}'
- 'POSTGRES_PASSWORD=${POSTGRES_PASSWORD}'
- 'POSTGRES_USER=${POSTGRES_USER}'
ports:
- '5432'

This file was deleted.

Loading
Loading