Running 4.15 on raspberry pi within docker container

xrak en 4 years ago

I am using this Dockerfile: https://github.com/traccar/traccar-docker/blob/master/Dockerfile.alpine
Building docker image fails since openjdk11-jre-headless package is not available for alpine linux on rapberry pi.
Can someone point me to other options to get this going. I tried with jdk8 but I ran into errors about a Class being at higher version than supported.
Thanks.

Anton Tananaev 4 years ago

You need Java 11.

xrak en 4 years ago

Love your short and prompt responses! The part about needing Java 11 was somewhat obvious based on the missing package name. I am hoping though that someone has pointers/instructions on an alternative path to get Traccar/jre-11 going on a docker container running on a raspberry pi 4.
A related question (if you know this off the top of your head) - which was the last version of Traccar that ran on java 8? I could go through all of the changelogs but if there a quick answer to this it will save me the time.
Thanks for a great product!

Anton Tananaev 4 years ago

which was the last version of Traccar that ran on java 8?

The easiest option is to check grade file history.

xrak en 4 years ago

After a bit of googling and experimenting ended up with this working version of Dockerfile to get you up and running on a raspberry pi docker container.

FROM adoptopenjdk/openjdk11 as jre-build
RUN $JAVA_HOME/bin/jlink \
         --add-modules java.base,java.logging,java.sql,java.naming,java.desktop,java.management \
         --strip-debug \
         --no-man-pages \
         --no-header-files \
         --compress=2 \
         --output /javaruntime

FROM debian:buster-slim
ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=jre-build /javaruntime $JAVA_HOME

ENV TRACCAR_VERSION 4.15
WORKDIR /opt/traccar
RUN apt-get -yq update && \
    apt-get -yq --no-install-recommends install wget unzip && \
    wget -qO /tmp/traccar.zip https://github.com/traccar/traccar/releases/download/v$TRACCAR_VERSION/traccar-other-$TRACCAR_VERSION.zip && \
    unzip -qo /tmp/traccar.zip -d /opt/traccar && \
    rm /tmp/traccar.zip

CMD ["java", "-Xms512m", "-Xmx512m", "-Djava.net.preferIPv4Stack=true", "-jar", "tracker-server.jar", "conf/traccar.xml"]