-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from don-bigdad/add-docker
Add docker
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
MYSQLDB_ROOT_PASSWORD= | ||
MYSQLDB_DATABASE= | ||
MYSQLDB_LOCAL_PORT=3307 | ||
MYSQLDB_DOCKER_PORT=3306 | ||
SPRING_LOCAL_PORT=8088 | ||
SPRING_DOCKER_PORT=8080 | ||
DEBUG_PORT=5005 | ||
MYSQLDB_USER= | ||
JWT_EXPIRATION= | ||
JWT_SECRET= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Builder stage | ||
FROM openjdk:17-jdk-slim as builder | ||
WORKDIR application | ||
ARG JAR_FILE=target/*.jar | ||
COPY ${JAR_FILE} booking-app.jar | ||
RUN java -Djarmode=layertools -jar booking-app.jar extract | ||
|
||
#Final stage | ||
FROM openjdk:17-jdk-slim | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
version: "3.8" | ||
|
||
services: | ||
book-shop-db: | ||
container_name: book-shop-db | ||
image: mysql:8 | ||
restart: unless-stopped | ||
env_file: ./.env | ||
ports: | ||
- $MYSQLDB_LOCAL_PORT:$MYSQLDB_DOCKER_PORT | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=$MYSQLDB_ROOT_PASSWORD | ||
- MYSQL_DATABASE=$MYSQLDB_DATABASE | ||
book-app: | ||
build: . | ||
container_name: book-app | ||
image: book-app | ||
restart: on-failure | ||
depends_on: | ||
- book-shop-db | ||
env_file: ./.env | ||
ports: | ||
- $SPRING_LOCAL_PORT:$SPRING_DOCKER_PORT | ||
- $DEBUG_PORT:$DEBUG_PORT | ||
environment: | ||
SPRING_APPLICATION_JSON: '{ | ||
"spring.datasource.url" : "jdbc:mysql://book-shop-db:$MYSQLDB_DOCKER_PORT/$MYSQLDB_DATABASE?serverTimezone=UTC", | ||
"spring.datasource.username" : "$MYSQLDB_USER", | ||
"spring.datasource.password" : "$MYSQLDB_ROOT_PASSWORD", | ||
"spring.datasource.driverClassName" : "com.mysql.cj.jdbc.Driver" | ||
}' | ||
JAVA_TOOL_OPTIONS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" |