wkrzywiec / kanban-board

Single-click full-stack application (Postgres, Spring Boot & Angular) using Docker Compose

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using JDK 11 Error

hendisantika opened this issue · comments

HI @wkrzywiec , I have an error when Using JDK 11.

I am using this Dockerfile:

FROM maven:3.6.3-jdk-11-slim AS build
MAINTAINER Hendi Santika "hendisantika@yahoo.co.id"
RUN mkdir -p /workspace
WORKDIR /workspace
COPY pom.xml /workspace
COPY src /workspace/src
RUN mvn -f pom.xml clean package
FROM adoptopenjdk/openjdk11:alpine-jre
COPY --from=build /workspace/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/application.jar"]

The error as follow:

org.postgresql.util.PSQLException: The connection attempt failed.
Caused by: java.net.UnknownHostException: ${DB_SERVER}

Do You have any suggestion to fix ${DB_SERVER} running?

Thanks

Hi @hendisantika,

The reason you have this error is because in order to run the application you need to have a Postgres database up and running and pass and address with credentials to it.

If you're using a docker compose file that's in this project simply run the command docker-compose up -d kanban-app (if you want to run only backend service) or docker-compose up -d (it will spin up both backend and frontend apps). In both cases predefined Postgres Docker container will be running together with backend application.

If you prefer to run a standalone backend, using Docker CLI you would need to pass env variables:

  • DB_SERVER - address of postgres server
  • POSTGRES_DB - name of the database
  • POSTGRES_USER - postgres user
  • POSTGRES_PASSWORD - user's password

a CLI command could look like this docker run -e DB_SERVER=localhost:5432 -e POSTGRES_DB=kanaban .... depending on your setup.

Let me know if that helped You.

I copy your code to make sure I can run your project well.
I change the JDK into JDK11 then change the docker file & docker compose version. Then run with docker-compose up but I have an error like I said above.

Could You check my repository here https://gitlab.com/hendisantika/kanban-board

All right, I didn't have time to take a closer look, but this problem seems to occur during running tests. Therefore I've just add skip-test flag to your Dockerfile.

RUN mvn -f pom.xml clean package -DskipTests

It fixed the problem, but there is another one with location of a .jar file. I can have a look on it maybe tomorrow, but until than you maybe find the solution for this next problem.

And of course I'll also anylize why after changing a Java version this problem occurs. But probably later next week

OK Thank.