DockerHub Image broken
I started the docker image with
docker run
--name Darkhold
--restart unless-stopped
-v "./Darkhold/db:/tmp/db"
-p 8181:8181/tcp
surajcm/darkhold
. It somehow started to download gradle? After signing up with test test I get a lot of errors that EL1004E: Method call: Method getUsername() cannot be found on type java.lang.String
Hi, I did a Java upgrade and forgot to update the Dockerfile with the new Java version. It seems it was the issue. Could you please update the code (I just pushed the required change) and try again?
It is still not working.
Ah it's still the same old docker image. I'll try the main branch. Why do you always build the project from source? That seems pretty redundant. You can do a gradle build and pack the jar into the container (best is Alpine) and simply do at startup java -jar
A few tips:
- You can get the temporary directory by
System.getProperty("java.io.tmpdir"); - Tests should be contained in the test directory, not as a module as they are bundled into the release binary leading to a bigger size.
- A more sophisticated db like postgres or mysql would be good. They also support testcontainers leading to a better testability. If switching between NoSQL and SQL is not straightfoward something like MongoDB would be good. Or alternative a NoSQL database that runs as a separate service.
- And please remove the test module and move it into the tests directory. I can't compile the project because /tmp doesn't exist on a windows machine. Something like above code would fix that problem.
So I got the project started and got these messages when trying to login: 2023-06-16 23:49:55.538 INFO [http-nio-8181-exec-3] {transactionId=33651441-f470-45b8-9550-bce8635dbdc8} : c.q.d.l.c.LoginController: into loginMe 2023-06-16 23:49:59.967 INFO [http-nio-8181-exec-4] {transactionId=27aa80bd-6b1b-40d6-b829-3eecbc32bc90} : c.q.d.l.s.UserDetailsServiceImpl: requested user name is [email protected] 2023-06-16 23:49:59.969 INFO [http-nio-8181-exec-4] {transactionId=27aa80bd-6b1b-40d6-b829-3eecbc32bc90} : c.q.d.l.s.UserDetailsServiceImpl: current user -> User[id=3, name='Test', email='[email protected]', password='$2a$10$IETkLhJaSnIsMd4dwxmpNu.DmwqsNod91XckFts/nfy6MDExNRTtO', enabled='false', roles=[com.quiz.darkhold.login.entity.Role@6dd0c77a]] 2023-06-16 23:49:59.974 INFO [http-nio-8181-exec-9] {transactionId=01eec1ee-28ab-41fc-96c4-1e99fa6770c9} : c.q.d.l.c.LoginController: error is there ...
I can override users with my own credentials (this is one of the biggest problems. If someone finds out about this and wants to hijack an account. Simply create that one again and login)
The redirect on signup doesn't seem to work. I get back to the main page and when I try to login with that user I get above error message.
The error appears there because you only check if the error is null. In my case the string is blank.
I would love if you move to a more sophisticated framework like react. They have client side routing which is normally a lot more robust than the Spring Boot Server.
Thank you for these tips. I will try to address them. I plan to learn React and rewrite the UI part while keeping the backend as Java and also, planning to move everything to a NoSQL db, most probably to MongoDB.
You're welcome. Feel free to ask any questions if you get stuck.