I’ve been trying to build the aforementioned container for some time but I get a 500 error. Specifically:
web-1 | 2024-06-29 18:40:34,266 WARN [http-nio-8080-exec-6] spi.SqlExceptionHelper – SQL Error: 0, SQLState: 08S01
web-1 | 2024-06-29 18:40:34,266 ERROR [http-nio-8080-exec-6] spi.SqlExceptionHelper – Communications link failure
I tried to follow several guides and also some chatgpt directives but now I just have a lot of confusion in my head, I hope someone can enlighten me on what I should correct and how I should proceed. In summary I followed these steps:
-
went into the angular folder and did an ng build
-
moved the contents of the generated dist folder into the src/main/webapp folder
-
Open the desktop docker application
-
from the terminal, in the project root, launch mvn clean package and, subsequently, docker-compose up –build
-
got error 500
I’m not a docker expert but I managed to create classic containers that didn’t require the use of a database and without angular front-end.
My questions are:
-
Is it correct to insert the front-end like this in the webapp folder?
-
if I filled the db tables locally (in particular the product table) through a MainApplication class, how could I fill it before it “ends up” in the Docker container, through a script?
This is the github repository: https://github.com/Luca-Liseros-Ferrari/dockerComposeAttempt I hope someone can help me.
Anyway I also tried this .yml, which solves the sql connection problem but then generates a 404.
version: '3.9'
services:
db:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: edam15!k2Mp_
MYSQL_DATABASE: midoripoldblastdue
ports:
"3307:3306"
volumes:
- ./db:/docker-entrypoint-initdb.d
web:
image: tomcat:latest
# Environment variables do not appear to be getting loaded the first time Tomcat starts!
environment:
JDBC_URL: jdbc:mysql://db:3306/example_db?connectTimeout=0&socketTimeout=0&autoReconnect=true
JDBC_USER: root
JDBC_PASS: edam15!k2Mp_
ports:
- "80:8080"
volumes:
- ./tomcat/webapps:/usr/local/tomcat/webapps
links:
- db
I really don’t know how I should proceed, I hope someone can enlighten me. Thanks in advance.