diff --git a/.env.template b/.env.template
new file mode 100644
index 0000000..ac85abb
--- /dev/null
+++ b/.env.template
@@ -0,0 +1,8 @@
+MYSQLDB_ROOT_PASSWORD=your_root_password
+MYSQLDB_USERNAME=your_username
+MYSQLDB_DATABASE=your_database_name
+MYSQLDB_LOCAL_PORT=3307
+MYSQLDB_DOCKER_PORT=3306
+
+APP_LOCAL_PORT=8081
+APP_DOCKER_PORT=8080
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 667aaef..bceaed0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@ target/
.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
+.env
### STS ###
.apt_generated
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..cd98233
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,15 @@
+FROM eclipse-temurin:17-jdk-alpine AS builder
+WORKDIR application
+ARG JAR_FILE=target/*.jar
+COPY ${JAR_FILE} application.jar
+RUN java -Djarmode=layertools -jar application.jar extract
+
+
+FROM eclipse-temurin:17-jdk-alpine
+WORKDIR application
+COPY --from=builder application/dependencies/ ./
+COPY --from=builder application/spring-boot-loader/ ./
+COPY --from=builder application/snapshot-dependencies/ ./
+COPY --from=builder application/application/ ./
+ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
+EXPOSE 8080
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..cab1f4a
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,55 @@
+services:
+ mysqldb:
+ image: mysql:9.5.0
+ container_name: mysqldb
+ restart: unless-stopped
+ env_file:
+ - .env
+ environment:
+ MYSQL_ROOT_PASSWORD: ${MYSQLDB_ROOT_PASSWORD}
+ MYSQL_DATABASE: ${MYSQLDB_DATABASE}
+
+ ports:
+ - "${MYSQLDB_LOCAL_PORT}:${MYSQLDB_DOCKER_PORT}"
+
+ volumes:
+ - mysql_data:/var/lib/mysql
+
+ healthcheck:
+ test: [ "CMD-SHELL", "mysqladmin", "ping", "-h", "localhost" ]
+ interval: 30s
+ timeout: 30s
+ retries: 3
+ networks:
+ - bookstore-network
+
+ app:
+ image: bookstore
+ build: .
+ container_name: bookstore
+ depends_on:
+ - mysqldb
+
+ ports:
+ - "${APP_LOCAL_PORT}:${APP_DOCKER_PORT}"
+ - "${DEBUG_PORT}:${DEBUG_PORT}"
+
+ env_file:
+ - .env
+
+ environment:
+ SPRING_APPLICATION_JSON: '{
+ "spring.datasource.url" : "jdbc:mysql://mysqldb:$MYSQLDB_DOCKER_PORT/$MYSQLDB_DATABASE",
+ "spring.datasource.username" : "$MYSQLDB_USERNAME",
+ "spring.datasource.password" : "$MYSQLDB_ROOT_PASSWORD",
+ "spring.jpa.properties.hibernate.dialect" : "org.hibernate.dialect.MySQLDialect"
+ }'
+ JAVA_TOOL_OPTIONS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:$DEBUG_PORT"
+ networks:
+ - bookstore-network
+
+volumes:
+ mysql_data:
+networks:
+ bookstore-network:
+ driver: bridge
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index e11ce6f..f7c1ebe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -142,6 +142,11 @@
runtime
+
+ org.springframework.boot
+ spring-boot-docker-compose
+
+
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 6f4ffb4..d316b7e 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,7 +1,9 @@
-spring.application.name=spring
-spring.datasource.url=jdbc:mysql://localhost:3306/db?serverTimezone=UTC
-spring.datasource.username=root
-spring.datasource.password=andriiw010107aA
+spring.application.name=bookstore
+
+spring.datasource.url=jdbc:mysql://\
+ localhost:${MYSQLDB_DOCKER_PORT}/${MYSQLDB_DATABASE}?serverTimezone=UTC
+spring.datasource.username=${MYSQLDB_USERNAME}
+spring.datasource.password=${MYSQLDB_ROOT_PASSWORD}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=validate
@@ -9,6 +11,9 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.show-sql=true
spring.jackson.deserialization.fail-on-unknown-properties=true
+spring.config.import=optional:file:.env
+
+spring.docker.compose.enabled=false
-jwt.expiration=500000
-jwt.secret=imustspendmoretimeonmateacademytillendofthe2025
+jwt.expiration=${JWT_EXPIRATION}
+jwt.secret=${JWT_SECRET}