doquocang / FE-Enclave-Online-Exam

0 stars 0 forks source link

Ticket #18: Build backend docker image and using docker compose to connect backend and database #11

Open doquocang opened 4 months ago

doquocang commented 4 months ago

done: with building back-end image

Image

doquocang commented 4 months ago

learning: about port in docker ls

Image

doquocang commented 4 months ago

Image

doquocang commented 4 months ago

Come up with the idea: how to map Containers inside the same Compose (local) to outside of the Compose For example: map container app-1 (inside compose test) to azuresql (outside compose test):

Image

solution: using port

Image

new Ticket:

map Front end Container and Back end Container

doquocang commented 4 months ago

Comprehend:

Image

test-app-1 and test-sql-1 is in the same local network created by Docker, they have the save Gateway

Research about:

doquocang commented 4 months ago

Understand:

Image

-Port that container will listen:

Image

Image

doquocang commented 4 months ago

Understand:

Image

doquocang commented 4 months ago

Learning the basic of docker network

doquocang commented 4 months ago

Learning the basic of docker flags (-e, -d, -p, ...)

doquocang commented 4 months ago

Learn and create bridge network:

Image

checking network just created:

Image

inspecting network:

Image

doquocang commented 4 months ago

Create a sql server 2019 container:

Image

check container:

Image

doquocang commented 4 months ago

Import data Get access to root while running container and install

Image

Adding mssql-tools into environment path:

Image

Mount Script folder to Container:

Image

Check mount:

Image

Import database:

Image

Result:

Image

doquocang commented 4 months ago

SQL import error:

Image

doquocang commented 4 months ago

Connect database to External network:

Image

Check network:

Image

or:

Image

doquocang commented 4 months ago

Adjust spring.datasource.url (host name from localhost:1433 to enclave-sql2019:1433) application.properties in server:

Image

doquocang commented 4 months ago

Build a new server image:

Image

doquocang commented 4 months ago

create docker compose with external bridge docker network created before:

Image

doquocang commented 4 months ago

Run docker compose:

Image

doquocang commented 4 months ago

Install ping to check the connection between server and the database:

Install: Image

Check the connection from server to database:

Image

doquocang commented 4 months ago

Done with fixing the database, turned out the error was about Visual studio limit code line:

doquocang commented 4 months ago

testing the api and database

Image