Skip to content

Commit 4c2893c

Browse files
authored
Merge pull request #2 from javieraviles/feature/postgres-user-crud
Using h2 locally, postgres in Heroku
2 parents bfab8d3 + 683a10c commit 4c2893c

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ RUN chmod 775 /work /work/application \
2727
EXPOSE 8080
2828
USER 1001
2929

30-
CMD ["./application", "-Dquarkus.http.host=0.0.0.0", "-Dquarkus.http.port=${PORT}", "-Dquarkus.datasource.url=${JDBC_DATABASE_URL}", "-Dquarkus.datasource.username=${JDBC_DATABASE_USERNAME}", "-Dquarkus.datasource.password=${JDBC_DATABASE_PASSWORD}"]
30+
CMD ["./application", "-Dquarkus.http.host=0.0.0.0", "-Dquarkus.http.port=${PORT}", "-Dquarkus.datasource.url=${JDBC_DATABASE_URL}", "-Dquarkus.datasource.username=${JDBC_DATABASE_USERNAME}", "-Dquarkus.datasource.password=${JDBC_DATABASE_PASSWORD}", "-Dquarkus.datasource.driver=org.postgresql.Driver"]

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This is a **Github Flow** boilerplate project using **Quarkus** GraalVM native i
99
- [Integration Tests](#integration-tests)
1010
- [Sonar](#sonar)
1111
- [Wrapping up developer responsabilities](#wrapping-up-developer-responsabilities)
12+
- [Database](#database)
1213
- [Api docs](#api-docs)
1314
- [Quarkus](#quarkus)
1415
- [Running the application in dev mode](#running-the-application-in-dev-mode)
@@ -78,6 +79,8 @@ Even though the dashboard will always represent the quality status of master, is
7879
- Make sure integration tests still work. Introduce some if needed.
7980
- Make sure the technial debt in Sonar is the same or better when your code is merged.
8081

82+
## Database
83+
Locally, just for development purposes, an H2 database will be used. Once deployed, the application will use a *PostgreSQL* in Heroku. Connection details will get overriden as environment variables replaced in the `Dockerfile` CMD.
8184

8285
## Api docs
8386
Both [OpenAPI](https://quarkus-github-flow.herokuapp.com/openapi) and [Swagger-UI](https://quarkus-github-flow.herokuapp.com/swagger-ui) are available.

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
<artifactId>quarkus-junit5</artifactId>
4444
<scope>test</scope>
4545
</dependency>
46+
<dependency>
47+
<groupId>io.quarkus</groupId>
48+
<artifactId>quarkus-test-h2</artifactId>
49+
<scope>test</scope>
50+
</dependency>
4651
<dependency>
4752
<groupId>io.quarkus</groupId>
4853
<artifactId>quarkus-hibernate-validator</artifactId>

src/main/resources/application.properties

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# set DB - only mandatory part
2-
quarkus.datasource.url=jdbc:postgresql://192.168.99.111:5432/db
3-
quarkus.datasource.driver=org.postgresql.Driver
4-
quarkus.datasource.username=user
5-
quarkus.datasource.password=pass
2+
quarkus.datasource.url=jdbc:h2:tcp://localhost/mem:test
3+
quarkus.datasource.driver=org.h2.Driver
64

75
# Hibernate details
86
quarkus.hibernate-orm.log.sql=true

src/test/java/com/javieraviles/DeveloperResourceTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88

99
import org.junit.jupiter.api.Test;
1010

11+
import io.quarkus.test.common.QuarkusTestResource;
12+
import io.quarkus.test.h2.H2DatabaseTestResource;
1113
import io.quarkus.test.junit.QuarkusTest;
1214

1315
@QuarkusTest
16+
@QuarkusTestResource(H2DatabaseTestResource.class)
1417
public class DeveloperResourceTest {
1518

1619
@Inject

0 commit comments

Comments
 (0)