-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile.monitor
51 lines (38 loc) · 1.57 KB
/
Dockerfile.monitor
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
# syntax=docker/dockerfile:latest
FROM --platform=$BUILDPLATFORM golang:1.23-bullseye AS builder
WORKDIR /workspace
COPY go.mod go.sum ./
RUN go mod download
# Copy the go source
COPY Makefile.build Makefile
COPY cmd/device-monitor cmd/device-monitor
COPY pkg pkg
ARG TARGETOS TARGETARCH TARGETVARIANT
RUN if [[ -n "${TARGETVARIANT}" ]]; then export GOARM=${TARGETVARIANT}; fi
# Build
RUN --mount=type=cache,target=/root/.cache/go-build GOOS=$TARGETOS GOARCH=$TARGETARCH \
DEVICE_MONITOR_BUILD_OUTPUT_PATH=/build/bin/device-monitor \
make device-monitor
FROM debian:buster-slim
LABEL org.opencontainers.image.source https://github.com/janekbaraniewski/kubeserial
ENV container docker
ENV LC_ALL C
RUN sed -i 's/# dev/dev/g' /etc/apt/sources.list
RUN apt-get update \
&& apt-get install -y systemd udev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN cd /lib/systemd/system/sysinit.target.wants/ \
&& ls | grep -v systemd-tmpfiles-setup | xargs rm -f $1
RUN rm -f /lib/systemd/system/multi-user.target.wants/* \
/etc/systemd/system/*.wants/* \
/lib/systemd/system/local-fs.target.wants/* \
/lib/systemd/system/sockets.target.wants/*udev* \
/lib/systemd/system/sockets.target.wants/*initctl* \
/lib/systemd/system/basic.target.wants/* \
/lib/systemd/system/anaconda.target.wants/* \
/lib/systemd/system/plymouth* \
/lib/systemd/system/systemd-update-utmp*
COPY --from=builder /build/bin/device-monitor /go/bin/device-monitor
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/lib/systemd/systemd-udevd"]