Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (51 loc) · 1.87 KB
/
Copy pathDockerfile
File metadata and controls
56 lines (51 loc) · 1.87 KB
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
52
53
54
55
56
# Builds any SyMon component. Pick one with --target, for example:
# docker build --target collector -t symon-collector .
# docker-compose.yml uses this to run the whole stack for development.
FROM node:22-alpine AS web
WORKDIR /web
COPY client/web/package.json client/web/package-lock.json ./
RUN npm ci
COPY client/web ./
RUN npm run build
FROM golang:1.26-alpine AS build
# the version the binaries report, for example
# docker build --build-arg VERSION=$(git describe --tags --always --dirty) ...
# .git is not copied in, so without it they report "dev"
ARG VERSION=
ENV LDFLAGS="-X github.com/dhamith93/SyMon/internal/version.Version=${VERSION}"
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
COPY --from=web /web/dist ./client/web/dist
RUN for c in agent collector client; do \
CGO_ENABLED=0 go build -ldflags "$LDFLAGS" -o /out/$c ./$c || exit 1; \
done
# agent builds that new hosts download from the dashboard
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$LDFLAGS" -o /out/downloads/agent-linux-amd64 ./agent \
&& CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$LDFLAGS" -o /out/downloads/agent-linux-arm64 ./agent \
&& CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "$LDFLAGS" -o /out/downloads/agent-linux-arm ./agent
FROM alpine:3.22 AS collector
RUN adduser -D -H symon
WORKDIR /app
COPY --from=build /out/collector ./collector
COPY collector/alerts.json ./
USER symon
EXPOSE 9000
CMD ["./collector"]
FROM alpine:3.22 AS client
RUN adduser -D -H symon
WORKDIR /app
COPY --from=build /out/client ./client
COPY --from=build /out/downloads ./downloads
USER symon
EXPOSE 8080
CMD ["./client"]
FROM alpine:3.22 AS agent
RUN adduser -D -H symon
WORKDIR /app
COPY --from=build /out/agent ./agent
# sample tasks, only used when SYMON_TASKS_PATH points here
COPY agent/tasks.json ./tasks.json
USER symon
CMD ["./agent"]