Add teslamate container, update deployment to use local image
Some checks failed
Build Container / build (push) Failing after 18s
Some checks failed
Build Container / build (push) Failing after 18s
Builds TeslaMate v2.2.0 from source using upstream build process.
This commit is contained in:
parent
d1d45538b3
commit
79b35610b5
3 changed files with 99 additions and 1 deletions
|
|
@ -15,7 +15,7 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: teslamate
|
||||
image: teslamate/teslamate:2.2.0
|
||||
image: registry.ops.eblu.me/blumeops/teslamate:v1.0.0
|
||||
ports:
|
||||
- containerPort: 4000
|
||||
env:
|
||||
|
|
|
|||
75
containers/teslamate/Dockerfile
Normal file
75
containers/teslamate/Dockerfile
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
# TeslaMate - Tesla data logger
|
||||
# Based on upstream Dockerfile
|
||||
|
||||
ARG TESLAMATE_VERSION=v2.2.0
|
||||
|
||||
FROM elixir:1.18-otp-26 AS builder
|
||||
|
||||
ARG TESLAMATE_VERSION
|
||||
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y ca-certificates curl gnupg git \
|
||||
&& mkdir -p /etc/apt/keyrings \
|
||||
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
|
||||
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
|
||||
&& NODE_MAJOR=22 \
|
||||
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" \
|
||||
| tee /etc/apt/sources.list.d/nodesource.list \
|
||||
&& apt-get update \
|
||||
&& apt-get install nodejs -y \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN mix local.rebar --force && \
|
||||
mix local.hex --force
|
||||
|
||||
# Clone specific version
|
||||
RUN git clone --depth 1 --branch ${TESLAMATE_VERSION} \
|
||||
https://github.com/teslamate-org/teslamate.git /opt/app
|
||||
|
||||
ENV MIX_ENV=prod
|
||||
WORKDIR /opt/app
|
||||
|
||||
RUN mix deps.get --only $MIX_ENV
|
||||
RUN mix deps.compile
|
||||
|
||||
RUN npm ci --prefix ./assets --progress=false --no-audit --loglevel=error
|
||||
RUN mix assets.deploy
|
||||
|
||||
RUN mix compile
|
||||
RUN SKIP_LOCALE_DOWNLOAD=true mix release --path /opt/built
|
||||
|
||||
# Runtime image
|
||||
FROM debian:bookworm-slim AS app
|
||||
|
||||
ENV LANG=C.UTF-8 \
|
||||
SRTM_CACHE=/opt/app/.srtm_cache \
|
||||
HOME=/opt/app
|
||||
|
||||
WORKDIR $HOME
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libodbc2 \
|
||||
libsctp1 \
|
||||
libssl3 \
|
||||
libstdc++6 \
|
||||
netcat-openbsd \
|
||||
tini \
|
||||
tzdata \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& groupadd --gid 10001 --system nonroot \
|
||||
&& useradd --uid 10000 --system --gid nonroot --home-dir /home/nonroot --shell /sbin/nologin nonroot \
|
||||
&& chown -R nonroot:nonroot .
|
||||
|
||||
USER nonroot:nonroot
|
||||
COPY --chmod=555 entrypoint.sh /
|
||||
COPY --from=builder --chown=nonroot:nonroot --chmod=555 /opt/built .
|
||||
RUN mkdir $SRTM_CACHE
|
||||
|
||||
EXPOSE 4000
|
||||
|
||||
ENTRYPOINT ["tini", "--", "/bin/dash", "/entrypoint.sh"]
|
||||
CMD ["bin/teslamate", "start"]
|
||||
23
containers/teslamate/entrypoint.sh
Normal file
23
containers/teslamate/entrypoint.sh
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env dash
|
||||
set -e
|
||||
|
||||
: "${DATABASE_HOST:="127.0.0.1"}"
|
||||
: "${DATABASE_PORT:=5432}"
|
||||
: "${ULIMIT_MAX_NOFILE:=65536}"
|
||||
|
||||
# prevent memory bloat in some misconfigured versions of Docker/containerd
|
||||
# where the nofiles limit is very large. 0 means don't set it.
|
||||
if test "${ULIMIT_MAX_NOFILE}" != 0 && test "$(ulimit -n)" -gt "${ULIMIT_MAX_NOFILE}"; then
|
||||
ulimit -n "${ULIMIT_MAX_NOFILE}"
|
||||
fi
|
||||
|
||||
# wait until Postgres is ready
|
||||
while ! nc -z "${DATABASE_HOST}" "${DATABASE_PORT}" 2>/dev/null; do
|
||||
echo waiting for postgres at "${DATABASE_HOST}":"${DATABASE_PORT}"
|
||||
sleep 1s
|
||||
done
|
||||
|
||||
# apply migrations
|
||||
bin/teslamate eval "TeslaMate.Release.migrate"
|
||||
|
||||
exec "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue