PART 17 - How to deploy Spring boot & Mysql application to Docker

preview_player
Показать описание
in this video we will learn how to deploy Spring boot & Mysql application to Docker, the most Contanier Engine used for containerisation.
Docker comandes in comment below
and the project source code in my github account,

S U B S C R I B E 👉

S O U R C E C O D E

M Y R E P O S I T O R I E S

S L I D E S H A R E C O U R S E S

📩 C O N T A C T M E

Spring boot crud example with jpa mysql thymeleaf - Part 1

E-COMMERCE APPLICATION USING SPRING BOOT AND ANGULAR + SOURCE CODE 🔥

Timecodes
0:00 - Intro
1:57 - Start Docker
3:12 - Create network
3:42 - Create Mysql container
9:06 - Create Spring boot container
21:27 - Running application

#SpringBoot #DeployToDocker #DockerContainer
Рекомендации по теме
Комментарии
Автор

Docker comandes used for this tutorial:

1) Start docker
docker --version
sudo apt-get install docker.io -y
systemctl start docker


2) Create network
docker network create crud-app-network


3) Get mysql image from dockerhub
docker run --name mysql-db-container --network crud-app-network -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=crud-db -p 3306:3306 -d mysql:8


4) Inspect if the database named crud-db is created successfully
docker container exec -it containerID bash
mysql -P 3306 --protocol=tcp -uroot -p
show databases;
exit


6) Generate jar file of application
- Edit application properties:
spring.datasource.url =
spring.datasource.username = root
spring.datasource.password = root
- And run this co*mande:
mvn install -DskipTests


7) The docker file for spring boot project will be as follows

FROM openjdk:8
COPY ./my-crud-app.jar my-crud-app.jar
EXPOSE 9090
CMD ["java", "-jar", "my-crud-app.jar"]


8) Build the docker image for the spring boot application
docker image build -t crud-application .

9) run this as a container
docker run --network crud-app-network --name crud-app-container-container -p 9090:9090 -d crud-application

10)Check the logs of container
docker container logs -f idContainer


12)insert some data for testing:



insert into roles values (null, "ADMIN");
insert into roles values (null, "USER");

insert into users_roles values (1, 1);
insert into users_roles values (1, 2);

lhouceineouhamza
welcome to shbcf.ru