-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.fleet-telemetry
More file actions
91 lines (78 loc) Β· 3.96 KB
/
Copy pathDockerfile.fleet-telemetry
File metadata and controls
91 lines (78 loc) Β· 3.96 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Build Tesla Fleet Telemetry from a pinned upstream revision, applying the
# TeslaSync MQTT event-time envelope patch before compilation.
FROM golang:1.27-bookworm AS build
ARG FLEET_TELEMETRY_REF=8fbaa100bd365936dab6ecbf0e2d7070c4d765cb
ARG FLEET_TELEMETRY_ARCHIVE_SHA256=8a0e2cc31a3c962b4e6296687e75b5fb208fbbe53ccf928af220ec2bf7fdb355
ARG LOGRUS_VERSION=v1.9.3
ARG PAHO_MQTT_VERSION=v1.5.1
ARG GRPC_VERSION=v1.82.1
ARG GOOGLE_API_VERSION=v0.271.0
ARG X_NET_VERSION=v0.58.0
ARG X_TEXT_VERSION=v0.41.0
WORKDIR /build
RUN curl --fail --location --show-error --no-progress-meter \
--retry 8 --retry-all-errors --retry-delay 5 --retry-max-time 300 \
--connect-timeout 30 --max-time 300 \
--output fleet-telemetry.tar.gz \
"https://codeload.github.com/teslamotors/fleet-telemetry/tar.gz/${FLEET_TELEMETRY_REF}" \
&& echo "${FLEET_TELEMETRY_ARCHIVE_SHA256} fleet-telemetry.tar.gz" | sha256sum -c - \
&& mkdir -p /go/src/fleet-telemetry \
&& tar -xzf fleet-telemetry.tar.gz --strip-components=1 -C /go/src/fleet-telemetry \
&& rm fleet-telemetry.tar.gz
# The pinned upstream revision predates security fixes in these transitive
# modules. Keep the overrides explicit and reproducible until the source pin is
# advanced to an upstream revision that includes equivalent or newer versions.
WORKDIR /go/src/fleet-telemetry
RUN go get \
"github.com/eclipse/paho.mqtt.golang@${PAHO_MQTT_VERSION}" \
"github.com/sirupsen/logrus@${LOGRUS_VERSION}" \
"google.golang.org/grpc@${GRPC_VERSION}" \
"google.golang.org/api@${GOOGLE_API_VERSION}" \
"golang.org/x/net@${X_NET_VERSION}" \
"golang.org/x/text@${X_TEXT_VERSION}" \
&& go mod tidy
WORKDIR /build
RUN curl --fail --location --show-error --no-progress-meter \
--retry 8 --retry-all-errors --retry-delay 5 --retry-max-time 300 \
--connect-timeout 30 --max-time 300 \
--output libsodium-1.0.19.tar.gz \
"https://github.com/jedisct1/libsodium/releases/download/1.0.19-RELEASE/libsodium-1.0.19.tar.gz" \
&& echo "018d79fe0a045cca07331d37bd0cb57b2e838c51bc48fd837a1472e50068bbea libsodium-1.0.19.tar.gz" | sha256sum -c - \
&& tar -xzf libsodium-1.0.19.tar.gz
WORKDIR /build/libsodium-stable
RUN ./configure --disable-shared --enable-static \
&& make -j"$(nproc)" \
&& make install
WORKDIR /build
RUN curl --fail --location --show-error --no-progress-meter \
--retry 8 --retry-all-errors --retry-delay 5 --retry-max-time 300 \
--connect-timeout 30 --max-time 300 \
--output zeromq-4.3.4.tar.gz \
"https://github.com/zeromq/libzmq/releases/download/v4.3.4/zeromq-4.3.4.tar.gz" \
&& echo "c593001a89f5a85dd2ddf564805deb860e02471171b3f204944857336295c3e5 zeromq-4.3.4.tar.gz" | sha256sum -c - \
&& tar -xzf zeromq-4.3.4.tar.gz
WORKDIR /build/zeromq-4.3.4
RUN ./configure --enable-static --disable-shared --disable-Werror \
&& make -j"$(nproc)" \
&& make install
RUN apt-get update \
&& apt-get install -y --no-install-recommends patch \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /go/src/fleet-telemetry
COPY build/fleet-telemetry/mqtt-event-time.patch /tmp/mqtt-event-time.patch
COPY build/fleet-telemetry/event_time_patch_test.go datastore/mqtt/event_time_patch_test.go
RUN sed -i 's/\r$//' /tmp/mqtt-event-time.patch \
&& patch -p1 < /tmp/mqtt-event-time.patch
ENV CGO_ENABLED=1
ENV CGO_LDFLAGS="-lstdc++"
RUN go test -tags fleettelemetry_patch ./datastore/mqtt -count=1 \
&& make build
FROM gcr.io/distroless/cc-debian12:nonroot
LABEL org.opencontainers.image.source="https://github.com/ev-dev-labs/teslasync" \
org.opencontainers.image.description="Tesla Fleet Telemetry with TeslaSync replay-safe MQTT event timestamps" \
org.opencontainers.image.licenses="Apache-2.0"
COPY --from=build /go/bin/fleet-telemetry /fleet-telemetry
COPY --from=build /go/src/fleet-telemetry/LICENSE /licenses/fleet-telemetry/LICENSE
USER nonroot:nonroot
ENTRYPOINT ["/fleet-telemetry"]
CMD ["-config", "/etc/fleet-telemetry/config.json"]