diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..6e754e1 --- /dev/null +++ b/.env.sample @@ -0,0 +1,4 @@ +PG_HOST= +PG_PORT= +PG_USER= +PG_PASSWORD= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 549e00a..526255e 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ build/ ### VS Code ### .vscode/ +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 479af06..96f7b28 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM maven +RUN apt update && apt install -y inotify-tools + WORKDIR /app COPY mvnw . @@ -10,4 +12,4 @@ COPY src src RUN mvn install -DskipTests RUN mvn compiler:compile -CMD ["mvn", "spring-boot:run"] \ No newline at end of file +COPY run.sh run.sh diff --git a/docker-compose.yml b/docker-compose.yml index eff714f..f3e39c4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,9 +3,16 @@ services: build: context: . dockerfile: Dockerfile + command: sh run.sh container_name: api_java + env_file: + - .env + volumes: + - ./src:/app/src ports: - "8080:8080" + - "35729:35729" + - "5005:5005" db: image: postgres diff --git a/pom.xml b/pom.xml index e445472..c7cde22 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,12 @@ test + + org.springframework.boot + spring-boot-devtools + true + + org.hibernate.validator diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..35d581e --- /dev/null +++ b/run.sh @@ -0,0 +1,5 @@ +#!/bin/bash +mvn spring-boot:run -Dspring-boot.run.jvmArguments="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" & +while true; do + inotifywait -e modify,create,delete,move -r ./src/ && mvn compile +done \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ca49535..c7871cb 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,11 @@ -spring.datasource.url=jdbc:postgresql://db:5432/api_java -spring.datasource.username=postgres -spring.datasource.password=postgres - +spring.datasource.url=jdbc:postgresql://${PG_HOST}:${PG_PORT}/api_java +spring.datasource.username=${PG_USER} +spring.datasource.password=${PG_PASSWORD} +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect spring.jpa.show-sql=true -spring.jpa.hibernate.ddl-auto=update \ No newline at end of file +spring.jpa.hibernate.ddl-auto=update +spring.devtools.livereload.enabled=true +spring.devtools.restart.enabled=true +spring.devtools.restart.poll-interval=2s +spring.devtools.restart.quiet-period=1s \ No newline at end of file