diff options
author | Iván Ávalos <avalos@disroot.org> | 2024-03-07 23:45:25 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2024-03-07 23:45:25 -0600 |
commit | 4058783ae3d6a31929e047c2440efc3b785675d5 (patch) | |
tree | b5d4cebb01c40f0cc597624f816f5f748b0d0fec | |
parent | 85eaea7c721de89a07e75a6ac5fd4c960aed9fdc (diff) | |
download | trackermap-server-4058783ae3d6a31929e047c2440efc3b785675d5.tar.gz trackermap-server-4058783ae3d6a31929e047c2440efc3b785675d5.tar.bz2 trackermap-server-4058783ae3d6a31929e047c2440efc3b785675d5.zip |
Add Dockerfile and docker-compose.yml
-rw-r--r-- | Dockerfile | 65 | ||||
-rw-r--r-- | docker-compose.yml | 17 |
2 files changed, 82 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..90d28a8dc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,65 @@ +FROM alpine:3.18 + +######################## +# Build Traccar server # +######################## + +RUN apk add --no-cache --no-progress \ + gcompat \ + libgcc \ + libstdc++ \ + openjdk11-jre-headless + +WORKDIR /opt/build-server + +ADD build.gradle ./ +ADD gradle ./gradle +ADD gradlew ./ +ADD settings.gradle ./ +ADD src ./src + +RUN ./gradlew assemble + +#################### +# Build Traccar UI # +#################### + +RUN apk add --no-cache --no-progress npm + +WORKDIR /opt/build-modern + +ADD traccar-web/modern/.eslintrc.json ./ +ADD traccar-web/modern/.npmrc ./ +ADD traccar-web/modern/index.html ./ +ADD traccar-web/modern/package.json ./ +ADD traccar-web/modern/package-lock.json ./ +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 && \ + npm install && \ + npm run build + +################## +# Deploy locally # +################## + +RUN mkdir -p /opt/traccar && \ + cp -r /opt/build-server/target/* /opt/traccar/ && \ + cp -r /opt/build-modern/build /opt/traccar/modern + +ADD schema /opt/traccar/schema +ADD templates /opt/traccar/templates + +########### +# Cleanup # +########### + +RUN rm -r /opt/build-server && \ + rm -r /opt/build-modern + +WORKDIR /opt/traccar + +CMD ["/usr/bin/java", "-Xms1g", "-Xms1g", "-jar", "tracker-server.jar", "-c", "conf/traccar.xml"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..434f12de0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3' + +services: + trackermap: + build: + context: . + dockerfile: Dockerfile + # Configure memory limits here! + command: ["/usr/bin/java", "-Xms1g", "-Xms1g", "-Xss1m", "-jar", "tracker-server.jar", "-c", "conf/traccar.xml"] + ports: + - 8082:8082 + - 5001-5211:5001-5211 + volumes: + - ./conf:/opt/traccar/conf:ro + - ./data:/opt/traccar/data + - ./logs:/opt/traccar/logs + - ./media:/opt/traccar/media |