diff options
Diffstat (limited to 'Dockerfile')
-rw-r--r-- | Dockerfile | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/Dockerfile b/Dockerfile index 14733c0a1..e73f81f7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,4 @@ -FROM alpine:3.18 - -ARG GIT_COMMIT=unspecified -LABEL git_commit=$GIT_COMMIT +FROM alpine:3.18 as build_server ######################## # Build Traccar server # @@ -13,7 +10,7 @@ RUN apk add --no-cache --no-progress \ libstdc++ \ openjdk11-jre-headless -WORKDIR /opt/build-server +WORKDIR /build ADD build.gradle ./ ADD gradle ./gradle @@ -23,14 +20,17 @@ 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 /opt/build-modern +WORKDIR /build +ADD traccar-web/modern/.env ./ ADD traccar-web/modern/.eslintrc.json ./ ADD traccar-web/modern/.npmrc ./ ADD traccar-web/modern/index.html ./ @@ -40,32 +40,31 @@ ADD traccar-web/modern/vite.config.js ./ ADD traccar-web/modern/public/ ./public ADD traccar-web/modern/src/ ./src -RUN echo "ESLINT_NO_DEV_ERRORS=false" > .env && \ - echo 'VITE_APP_VERSION=$npm_package_version' >> .env && \ - echo 'timeout=60000' > ~/.npmrc && \ +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 mkdir -p /opt/traccar && \ - cp -r /opt/build-server/target/* /opt/traccar/ && \ - cp -r /opt/build-modern/build /opt/traccar/modern +RUN apk add --no-cache --no-progress openjdk11-jre-headless -ADD setup/default.xml /opt/traccar/conf/default.xml -ADD setup/traccar.xml /opt/traccar/conf/traccar.xml -ADD schema /opt/traccar/schema -ADD templates /opt/traccar/templates +WORKDIR /opt/traccar -########### -# Cleanup # -########### +COPY --from=build_server /build/target . +COPY --from=build_web /build/build ./modern -RUN rm -r /opt/build-server && \ - rm -r /opt/build-modern +ADD setup/default.xml ./conf/default.xml +ADD setup/traccar.xml ./conf/traccar.xml +ADD schema ./schema +ADD templates ./templates -WORKDIR /opt/traccar +RUN mkdir logs/ data/ media/ CMD ["/usr/bin/java", "-Xms1g", "-Xms1g", "-jar", "tracker-server.jar", "-c", "conf/traccar.xml"] |