-
Notifications
You must be signed in to change notification settings - Fork 26
Add sample using Docker Compose #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: [email protected] <[email protected]>
|
This is not expected work requested in #291 Here is the document for Docker Compose support in Spring Boot. You should create a project from Spring Initializr with "Docker Compose Support" dependency included. |
…pose support (#291) Co-Authored-By: [email protected] <[email protected]>
Co-Authored-By: [email protected] <[email protected]>
| @@ -0,0 +1,9 @@ | |||
| services: | |||
| postgres: | |||
There was a problem hiding this comment.
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
| @@ -0,0 +1,33 @@ | |||
| # Getting Started | |||
There was a problem hiding this comment.
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
| "spring.datasource.password=", | ||
| "spring.datasource.driver-class-name=org.h2.Driver", | ||
| "doma.dialect=H2" | ||
| "spring.datasource.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use docker compose in tests as well. That means PostgreSQL should be used in tests instead of H2.
By default, Spring Boot’s Docker Compose support is disabled when running tests.
To enable Docker Compose support in tests, set spring.docker.compose.skip.in-tests to false.
| "spring.datasource.password=", | ||
| "spring.datasource.driver-class-name=org.h2.Driver", | ||
| "doma.dialect=H2" | ||
| "spring.docker.compose.skip.in-tests=false", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated with application.properties
| @@ -0,0 +1,3 @@ | |||
| # Enable Docker Compose in tests | |||
| spring.docker.compose.skip.in-tests=false | |||
| doma.dialect=POSTGRES | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doma.dialect should be automatically detected by JdbcConnectionDetails
| </dependency> | ||
| <dependency> | ||
| <groupId>com.h2database</groupId> | ||
| <artifactId>h2</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
H2 is no longer needed
| The PostgreSQL configuration is defined in the `compose.yaml` file: | ||
|
|
||
| ```yaml | ||
| services: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update README
|
@devin-ai-integration rebase the master branch. Add the same tests as in #310, and reflect the review comments in this PR as well. |
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this dependency as it's included in spring-boot-starter-test
|
|
||
| # Doma configuration | ||
| doma.dialect=POSTGRES | ||
| logging.level.org.springframework.jdbc.datasource.DataSourceTransactionManager=DEBUG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataSourceTransactionManager is old. Use JdbcTransactionManager instead.
logging.level.org.springframework.jdbc.support.JdbcTransactionManager=DEBUG
| # Enable Docker Compose in tests | ||
| spring.docker.compose.skip.in-tests=false | ||
| spring.sql.init.mode=always | ||
| spring.sql.init.schema-locations=classpath:schema-test.sql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like having to manage the data twice using schema-test.sql and schema.sql. Instead of using schema-test.sql for testing, perform the reset process in the test code.
… config, remove JUnit dependency Co-Authored-By: [email protected] <[email protected]>
| spring.sql.init.schema-locations=classpath:schema-test.sql | ||
|
|
||
| # Database configuration | ||
| spring.datasource.url=jdbc:postgresql://localhost:5432/mydatabase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spring.datasource.* props are useless as these are automatically resolved via Docker Compose based JdbcConnectionDetails
| @@ -1,13 +1,12 @@ | |||
| # Enable Docker Compose in tests | |||
| spring.docker.compose.skip.in-tests=false | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove src/test/resources/application.properties. Using src/main/resources/application.properties should be sufficient
…ation.properties Co-Authored-By: [email protected] <[email protected]>
| @@ -1,12 +0,0 @@ | |||
| # Enable Docker Compose in tests | |||
| spring.docker.compose.skip.in-tests=false | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move spring.docker.compose.skip.in-tests=false to src/main/resources/application.properties
Co-Authored-By: [email protected] <[email protected]>
This reverts commit bd35370.
This reverts commit b616f81.
Add sample using Docker Compose
This PR adds a new sample demonstrating how to use Doma Spring Boot with Docker Compose and PostgreSQL.
The sample includes:
Fixes #291
Link to Devin run: https://app.devin.ai/sessions/5c0405d96184477a850a6cac86d421c5
Requested by: [email protected]