towerops-agent/Dockerfile
Graham McIntire abde949455
feat: show build date on agent startup
Inject build timestamp via ldflags during Docker build so the
agent logs when the binary was compiled.
2026-03-24 12:56:11 -05:00

20 lines
767 B
Docker

FROM golang:1.25-alpine3.23 AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY . .
ARG VERSION=dev
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=${VERSION} -X main.buildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o towerops-agent .
FROM alpine:3.23
RUN apk add --no-cache ca-certificates iputils libcap
COPY --from=builder /app/towerops-agent /usr/local/bin/towerops-agent
RUN adduser -D -u 1000 towerops && \
chown towerops /usr/local/bin/towerops-agent && \
setcap cap_net_raw+ep /usr/local/bin/towerops-agent && \
setcap cap_net_raw+p /bin/ping
USER towerops
CMD ["towerops-agent"]