Rudolf-Barbu / Ward

Server dashboard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add ability to build JAR with docker

Keeo opened this issue · comments

It would be cool to modify dockerfile to allow building from withint the docker using staged build. That way one would not need to install java on host in order to run this. I tried to do it like this but it crashes after setup.

docker run --rm -it --name ward -p 4000:4000 -p 5000:5000 --privileged ward
2020-07-19 09:46:45.152  INFO 8 --- [nio-5000-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-07-19 09:46:45.153  INFO 8 --- [nio-5000-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-07-19 09:46:45.157  INFO 8 --- [nio-5000-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 4 ms
2020-07-19 09:46:45.278 ERROR 8 --- [nio-5000-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception

java.io.FileNotFoundException: pom.xml (No such file or directory)
	at java.io.FileInputStream.open0(Native Method) ~[na:1.8.0_262]
	at java.io.FileInputStream.open(FileInputStream.java:195) ~[na:1.8.0_262]
	at java.io.FileInputStream.<init>(FileInputStream.java:138) ~[na:1.8.0_262]
	at java.io.FileInputStream.<init>(FileInputStream.java:93) ~[na:1.8.0_262]
	at java.io.FileReader.<init>(FileReader.java:58) ~[na:1.8.0_262]
	at org.bsoftware.ward.services.implementation.InfoService.getMavenDto(InfoService.java:224) ~[classes!/:1.6.0]
	at org.bsoftware.ward.services.implementation.InfoService.get(InfoService.java:247) ~[classes!/:1.6.0]
	at org.bsoftware.ward.controllers.IndexController.getIndex(IndexController.java:49) ~[classes!/:1.6.0]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_262]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_262]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_262]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_262]
FROM maven:3.6.3-jdk-8 as builder
COPY . .
RUN mvn clean package

FROM adoptopenjdk:8-jre-hotspot
ARG USER=user
RUN apt-get update && \
    apt-get install -y sudo && \
    apt-get install -yq dmidecode && \
    rm -rf /var/lib/apt/lists/*

RUN adduser --disabled-password --gecos '' $USER

RUN adduser $USER sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/$USER
USER $USER
RUN sudo ln -s $JAVA_HOME/bin/java /usr/bin/java
COPY --from=builder target/*.jar /ward.jar
EXPOSE 4000
ENTRYPOINT sudo java -jar ward.jar

I'm sorry, I never worked with Doker. So, i can't help in this situation. Where are several contributors, which created instructions for that case. If these instructions doesn't work for you and you can fix this issue - i will merge your pull request. Or you may ask help from others contributors. Kind regards.

Thats all right. I managed to get it working so I'll create PR later today 👍

Fixed by #34