File size: 1,591 Bytes
3959f31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM --platform=$BUILDPLATFORM golang:bookworm AS builder

WORKDIR /app

COPY ../go.mod ../go.sum ./
RUN go mod download

# Copy source files
COPY . ./

# Build
ARG TARGETOS TARGETARCH
RUN CGO_ENABLED=0 GOGC=75 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -tags glibc -ldflags "-w -s" -o /agent ./internal/cmd/agent

# --------------------------
# Smartmontools builder stage
# --------------------------
FROM nvidia/cuda:12.2.2-base-ubuntu22.04 AS smartmontools-builder

RUN apt-get update && apt-get install -y \
  wget \
  build-essential \
  && wget https://downloads.sourceforge.net/project/smartmontools/smartmontools/7.5/smartmontools-7.5.tar.gz \
  && tar zxvf smartmontools-7.5.tar.gz \
  && cd smartmontools-7.5 \
  && ./configure --prefix=/usr --sysconfdir=/etc \
  && make \
  && make install \
  && rm -rf /smartmontools-7.5* \
  && apt-get remove -y wget build-essential \
  && apt-get autoremove -y \
  && rm -rf /var/lib/apt/lists/*

# --------------------------
# Final image: GPU-enabled agent with nvidia-smi
# --------------------------
FROM nvidia/cuda:12.2.2-base-ubuntu22.04
COPY --from=builder /agent /agent

# AMD GPU name lookup (used by agent on hybrid laptops when /usr/share/libdrm/amdgpu.ids is read)
COPY --from=builder /app/agent/test-data/amdgpu.ids /usr/share/libdrm/amdgpu.ids

# Copy smartmontools binaries and config files
COPY --from=smartmontools-builder /usr/sbin/smartctl /usr/sbin/smartctl

# Ensure data persistence across container recreations
VOLUME ["/var/lib/beszel-agent"]

ENTRYPOINT ["/agent"]