diff --git a/.Dockerfile b/.Dockerfile new file mode 100644 index 0000000..6fa3d00 --- /dev/null +++ b/.Dockerfile @@ -0,0 +1,16 @@ +# Builder stage +FROM openjdk: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 + +# Final stage +FROM openjdk: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.JarLauncher"] +EXPOSE 8080 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 549e00a..c899ede 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ HELP.md target/ +.env !.mvn/wrapper/maven-wrapper.jar !**/src/main/**/target/ !**/src/test/**/target/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b246b46 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +version: '3.8' + +services: + mysqldb: + image: mysql + restart: always + env_file: ./.env + environment: + - MYSQL_ROOT_PASSWORD=$MYSQLDB_ROOT_PASSWORD + - MYSQLDB_DATABASE=$MYSQLDB_DATABASE + ports: + - $MYSQLDB_LOCAL_PORT:$MYSQLDB_DOCKER_PORT + app: + depends_on: + - mysqldb + restart: on-failure + image: online-book-store + build: . + env_file: ./.env + ports: + - $SPRING_LOCAL_PORT:$SPRING_DOCKER_PORT + - $DEBUG_PORT:$DEBUG_PORT + environment: + SPRING_APPLICATION_JSON: '{ + "spring.datasource.url" : "jdbc:mysql://mysqldb:$MYSQLDB_DOCKER_PORT/$MYSQLDB_DATABASE?createDatabaseIfNotExist=true", + "spring.datasource.username" : "$MYSQLDB_USER", + "spring.datasource.password" : "$MYSQLDB_ROOT_PASSWORD", + "spring.jpa.properties.hibernate.dialect" : "org.hibernate.dialect.MySQL8Dialect", + "spring.jpa.hibernate.ddl-auto" : "validate" + }' + JAVA_TOOL_OPTIONS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" \ No newline at end of file