mirror of
https://github.com/teslamate-org/teslamate.git
synced 2026-01-24 21:06:08 +08:00
For consistency with the `entrypoint.sh` script's shebang (`#!/usr/bin/env dash`), this change updates the Dockerfile's ENTRYPOINT to call `/bin/dash` directly instead of `/bin/sh`. This makes the choice of shell explicit and ensures the script is always executed by the intended interpreter, regardless of what `/bin/sh` might point to in future base images.
81 lines
2.3 KiB
Docker
81 lines
2.3 KiB
Docker
FROM elixir:1.18.4-otp-26 AS builder
|
|
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y ca-certificates curl gnupg \
|
|
&& 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
|
|
|
|
ENV MIX_ENV=prod
|
|
WORKDIR /opt/app
|
|
|
|
COPY mix.exs mix.lock ./
|
|
RUN mix deps.get --only $MIX_ENV
|
|
|
|
COPY config/$MIX_ENV.exs config/$MIX_ENV.exs
|
|
COPY config/config.exs config/config.exs
|
|
RUN mix deps.compile
|
|
|
|
COPY assets/package.json assets/package-lock.json ./assets/
|
|
RUN npm ci --prefix ./assets --progress=false --no-audit --loglevel=error
|
|
|
|
COPY assets assets
|
|
COPY priv/static priv/static
|
|
RUN mix assets.deploy
|
|
|
|
COPY lib lib
|
|
COPY priv/repo/migrations priv/repo/migrations
|
|
COPY priv/gettext priv/gettext
|
|
COPY grafana/dashboards grafana/dashboards
|
|
COPY VERSION VERSION
|
|
RUN mix compile
|
|
|
|
COPY config/runtime.exs config/runtime.exs
|
|
RUN SKIP_LOCALE_DOWNLOAD=true mix release --path /opt/built
|
|
|
|
########################################################################
|
|
|
|
FROM debian:trixie-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 \
|
|
libssl3t64 \
|
|
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 --chown=nonroot:nonroot --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"]
|