mirror of
https://github.com/AnalogJ/scrutiny.git
synced 2026-04-19 05:47:49 -04:00
* Remove old entry and dependencies from Makefile * Update Dockerfiles to only COPY needed files for faster builds and better caching * Test the docker files getting built from the Makefile in CI
101 lines
4.3 KiB
Docker
101 lines
4.3 KiB
Docker
# syntax=docker/dockerfile:1.4
|
|
########################################################################################################################
|
|
# Omnibus Image
|
|
########################################################################################################################
|
|
|
|
######## Build the frontend
|
|
FROM --platform=${BUILDPLATFORM} node AS frontendbuild
|
|
WORKDIR /go/src/github.com/analogj/scrutiny
|
|
COPY --link Makefile /go/src/github.com/analogj/scrutiny/
|
|
COPY --link webapp/frontend /go/src/github.com/analogj/scrutiny/webapp/frontend
|
|
|
|
RUN make binary-frontend
|
|
|
|
|
|
######## Build the backend
|
|
FROM golang:1.25-trixie as backendbuild
|
|
|
|
WORKDIR /go/src/github.com/analogj/scrutiny
|
|
COPY --link Makefile /go/src/github.com/analogj/scrutiny/
|
|
COPY --link go.mod go.sum /go/src/github.com/analogj/scrutiny/
|
|
COPY --link collector /go/src/github.com/analogj/scrutiny/collector
|
|
COPY --link webapp/backend /go/src/github.com/analogj/scrutiny/webapp/backend
|
|
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
|
|
apt-get install -y --no-install-recommends \
|
|
file \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
RUN make binary-clean binary-all WEB_BINARY_NAME=scrutiny
|
|
|
|
|
|
######## Build smartmontools from source
|
|
FROM debian:trixie-slim AS smartmontoolsbuild
|
|
ARG SMARTMONTOOLS_VER=7.5
|
|
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
|
|
apt-get install -y --no-install-recommends \
|
|
ca-certificates curl gcc g++ gnupg make \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
RUN curl -L "https://github.com/smartmontools/smartmontools/releases/download/RELEASE_$(echo ${SMARTMONTOOLS_VER} | tr '.' '_')/smartmontools-${SMARTMONTOOLS_VER}.tar.gz" -o /tmp/smartmontools.tar.gz \
|
|
&& tar -xzf /tmp/smartmontools.tar.gz -C /tmp \
|
|
&& cd /tmp/smartmontools-${SMARTMONTOOLS_VER} \
|
|
&& ./configure --prefix=/usr LDFLAGS='-static' --without-libcap-ng --without-libsystemd \
|
|
&& make -j"$(nproc)" \
|
|
&& make install \
|
|
&& /usr/sbin/update-smart-drivedb \
|
|
&& rm -rf /tmp/smartmontools*
|
|
|
|
|
|
######## Combine build artifacts in runtime image
|
|
FROM debian:trixie-slim AS runtime
|
|
ARG TARGETARCH
|
|
EXPOSE 8080
|
|
WORKDIR /opt/scrutiny
|
|
ENV PATH="/opt/scrutiny/bin:${PATH}"
|
|
ENV INFLUXD_CONFIG_PATH=/opt/scrutiny/influxdb
|
|
ENV S6VER="3.1.6.2"
|
|
ENV INFLUXVER="2.2.0"
|
|
ENV S6_SERVICES_READYTIME=1000
|
|
SHELL ["/usr/bin/sh", "-c"]
|
|
|
|
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
|
|
apt-get install -y --no-install-recommends \
|
|
ca-certificates \
|
|
cron \
|
|
curl \
|
|
tzdata \
|
|
procps \
|
|
xz-utils \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& update-ca-certificates \
|
|
&& case ${TARGETARCH} in \
|
|
"amd64") S6_ARCH=x86_64 ;; \
|
|
"arm64") S6_ARCH=aarch64 ;; \
|
|
esac \
|
|
&& curl https://github.com/just-containers/s6-overlay/releases/download/v${S6VER}/s6-overlay-noarch.tar.xz -L -s --output /tmp/s6-overlay-noarch.tar.xz \
|
|
&& tar -Jxpf /tmp/s6-overlay-noarch.tar.xz -C / \
|
|
&& rm -rf /tmp/s6-overlay-noarch.tar.xz \
|
|
&& curl https://github.com/just-containers/s6-overlay/releases/download/v${S6VER}/s6-overlay-${S6_ARCH}.tar.xz -L -s --output /tmp/s6-overlay-${S6_ARCH}.tar.xz \
|
|
&& tar -Jxpf /tmp/s6-overlay-${S6_ARCH}.tar.xz -C / \
|
|
&& rm -rf /tmp/s6-overlay-${S6_ARCH}.tar.xz
|
|
RUN curl -L https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXVER}-${TARGETARCH}.deb --output /tmp/influxdb2-${INFLUXVER}-${TARGETARCH}.deb \
|
|
&& dpkg -i --force-all /tmp/influxdb2-${INFLUXVER}-${TARGETARCH}.deb \
|
|
&& rm -rf /tmp/influxdb2-${INFLUXVER}-${TARGETARCH}.deb
|
|
|
|
COPY /rootfs /
|
|
|
|
COPY --from=smartmontoolsbuild /usr/sbin/smartctl /usr/sbin/smartctl
|
|
COPY --from=smartmontoolsbuild /usr/share/smartmontools/ /usr/share/smartmontools/
|
|
|
|
COPY --link --from=backendbuild --chmod=755 /go/src/github.com/analogj/scrutiny/scrutiny /opt/scrutiny/bin/
|
|
COPY --link --from=backendbuild --chmod=755 /go/src/github.com/analogj/scrutiny/scrutiny-collector-metrics /opt/scrutiny/bin/
|
|
COPY --link --from=frontendbuild --chmod=644 /go/src/github.com/analogj/scrutiny/dist /opt/scrutiny/web
|
|
RUN chmod 0644 /etc/cron.d/scrutiny && \
|
|
rm -f /etc/cron.daily/* && \
|
|
mkdir -p /opt/scrutiny/web && \
|
|
mkdir -p /opt/scrutiny/config && \
|
|
chmod -R ugo+rwx /opt/scrutiny/config && \
|
|
chmod +x /etc/cont-init.d/* && \
|
|
chmod +x /etc/services.d/*/run && \
|
|
chmod +x /etc/services.d/*/finish
|
|
|
|
CMD ["/init"]
|