aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-03-09 23:52:57 -0600
committerIván Ávalos <avalos@disroot.org>2024-03-09 23:52:57 -0600
commitcbdc38bfe04e95658d9308b5b5705f440d8508ff (patch)
treebedd6bf6d3ac73370f2c1690e5b3eeada9b26669
parentacff8c4dce2f46b7907e6e19118dbc0c9c8e90f1 (diff)
downloadtrackermap-server-trackermap-v0.1.3.tar.gz
trackermap-server-trackermap-v0.1.3.tar.bz2
trackermap-server-trackermap-v0.1.3.zip
Add Concourse pipeline and improve Dockerfiletrackermap-v0.1.3
-rw-r--r--Dockerfile43
-rw-r--r--pipeline.yml49
2 files changed, 70 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"]
diff --git a/pipeline.yml b/pipeline.yml
new file mode 100644
index 000000000..d588f100a
--- /dev/null
+++ b/pipeline.yml
@@ -0,0 +1,49 @@
+resources:
+ - name: trackermap-server-git
+ type: git
+ source:
+ uri: ((git-repo))
+ tag_filter: trackermap-*
+ fetch_tags: "true"
+
+ - name: docker-image
+ type: registry-image
+ icon: docker
+ source:
+ repository: ((registry-repo))
+ username: ((registry-username))
+ password: ((registry-password))
+
+jobs:
+ - name: build-and-publish
+ plan:
+ - get: trackermap-server-git
+ trigger: true
+ - task: build-docker
+ privileged: true
+ config:
+ platform: linux
+ image_resource:
+ type: registry-image
+ source:
+ repository: concourse/oci-build-task
+ tag: latest
+ inputs:
+ - name: trackermap-server-git
+ outputs:
+ - name: image
+ run:
+ path: sh
+ args:
+ - -exc
+ - |
+ cd trackermap-server-git/
+ git describe --tags | sed 's/trackermap-//' > ../image/tag
+ export BUILD_ARG_GIT_COMMIT=$(git rev-parse HEAD)
+ cd ../
+ export CONTEXT=trackermap-server-git
+ build
+ - put: docker-image
+ params:
+ image: image/image.tar
+ additional_tags: image/tag