aboutsummaryrefslogtreecommitdiff
path: root/Dockerfile
blob: 90d28a8dc0ade78034a16750675c9d983765c586 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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"]