FROM alpine:3.18 as build_server ######################## # Build Traccar server # ######################## RUN apk add --no-cache --no-progress \ gcompat \ libgcc \ libstdc++ \ openjdk17-jre-headless WORKDIR /build ADD build.gradle ./ ADD gradle ./gradle ADD gradlew ./ ADD settings.gradle ./ ADD src ./src RUN ./gradlew assemble FROM alpine:3.18 as build_web #################### # Build Traccar UI # #################### RUN apk add --no-cache --no-progress npm WORKDIR /build ADD traccar-web/.env ./ ADD traccar-web/.eslintrc.json ./ ADD traccar-web/.npmrc ./ ADD traccar-web/index.html ./ ADD traccar-web/package.json ./ ADD traccar-web/package-lock.json ./ ADD traccar-web/vite.config.js ./ ADD traccar-web/public/ ./public ADD traccar-web/src/ ./src RUN echo 'timeout=60000' > ~/.npmrc && \ npm install && \ npm run build FROM alpine:3.18 ARG GIT_COMMIT=unspecified LABEL git_commit=$GIT_COMMIT ################## # Deploy locally # ################## RUN apk add --no-cache --no-progress openjdk11-jre-headless WORKDIR /opt/traccar COPY --from=build_server /build/target . COPY --from=build_web /build/build ./web ADD setup/traccar.xml ./conf/traccar.xml ADD schema ./schema ADD templates ./templates RUN mkdir logs/ data/ media/ CMD ["/usr/bin/java", "-Xms1g", "-Xms1g", "-jar", "tracker-server.jar", "-c", "conf/traccar.xml"]