Skip to content

Commit ffd294b

Browse files
committed
updated dockerfile, provided readme for docker image creation and container execution
1 parent a1cb603 commit ffd294b

File tree

4 files changed

+50
-4
lines changed

4 files changed

+50
-4
lines changed

Dockerfile

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
FROM java:8-jdk
2-
COPY target/jukebox-*.jar jukebox.jar
1+
FROM arm64v8/openjdk:8
2+
RUN mkdir /app
3+
RUN cd /app
4+
COPY target/jukebox-0.0.1-SNAPSHOT.jar /app/jukebox.jar
5+
COPY config/production.properties /app/application.properties
6+
WORKDIR /app
37
EXPOSE 8080
4-
ENTRYPOINT ["java", "-jar", "jukebox.jar"]
8+
ENTRYPOINT ["java", "-jar", "jukebox.jar", "--spring.config.location=application.properties"]

config/production.properties

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
server.port=8080
2+
3+
#mysql database & Hibernate configuration
4+
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
5+
spring.datasource.url=jdbc:mysql://mysqldb/jukebox?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false
6+
spring.datasource.username=root
7+
spring.datasource.password=root
8+
spring.jpa.show-sql=true
9+
spring.jpa.hibernate.ddl-auto=update
10+
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
11+
spring.jpa.properties.hibernate.jdbc.time_zone=UTC
12+
13+
#Flyway configuration
14+
flyway.url=jdbc:mysql://mysqldb
15+
flyway.schemas=jukebox
16+
flyway.user=root
17+
flyway.password=root
18+
19+
#JWT configuration
20+
jukebox.app.jwtSecret=jukebox-client
21+
jukebox.app.jwtExpirationMs=86400000

docker-readme.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
1.docker network create jukebox-mysql
2+
3+
//since mysql is not available for the platform arm64/v8 (I'm using M1 Macbook Pro), we need to use MariaDb which has a support for the platform
4+
2.docker container run --name mysqldb --network jukebox-mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=jukebox -d arm64v8/mariadb
5+
6+
others can use the below mysql
7+
8+
2.docker container run --name mysqldb --network jukebox-mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=jukebox -d mysql:8
9+
10+
//To see the container bash, run the following command
11+
3. docker container exec -it <container-id> bash
12+
13+
//Use the same name of the mysql container in the jdbc url string in application.properties
14+
4. spring.datasource.url=jdbc:mysql://mysqldb/jukebox?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false
15+
16+
//build the springboot application image using the command
17+
5. docker image build -t jukebox:v1 .
18+
19+
20+
//Now run the built image as a container in the already existing network jukebox-mysql
21+
6. docker container run --network jukebox-mysql --name jukebox-jdbc-container -p 8080:8080 -d jukebox:v1

src/main/resources/application.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ server.port=8080
22

33
#mysql database & Hibernate configuration
44
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
5-
spring.datasource.url=jdbc:mysql://localhost:3306/jukebox?autoreconnect=true
5+
spring.datasource.url=jdbc:mysql://localhost:3306/jukebox?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false
66
spring.datasource.username=root
77
spring.datasource.password=password
88
spring.jpa.show-sql=true

0 commit comments

Comments
 (0)