2025-05-16 14:23:15 +02:00

47 lines
1.5 KiB
Docker

# Build the tool
FROM reg.cadoles.com/proxy_cache/library/golang:1.24 AS build
ARG VERSION=v1.0.0
COPY go.mod .
COPY go.sum .
COPY src src
RUN env CGO_ENABLED=0 go install -v -ldflags="-w -s -X main.version=${VERSION} -X 'main.BuildDate=$(/usr/bin/date --utc --rfc-3339=seconds)'" ./...
# Copy the tool and install gotmpl and wazuh
FROM reg.cadoles.com/proxy_cache/library/debian:12.10
ARG WAZUH_VERSION=4.11.1-1
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update -y && \
apt-get install -y gpg curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import && chmod 644 /usr/share/keyrings/wazuh.gpg
RUN echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | tee -a /etc/apt/sources.list.d/wazuh.list
RUN apt-get update && \
apt-get install -y wazuh-agent=$WAZUH_VERSION procps && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ARG GOMPLATE_VERSION=v4.3.2
# Install gomplate (little file templating engine: https://github.com/hairyhenderson/gomplate)
RUN curl -o /usr/local/bin/gomplate -sSL https://github.com/hairyhenderson/gomplate/releases/download/$GOMPLATE_VERSION/gomplate_linux-amd64 \
&& chmod +x /usr/local/bin/gomplate
COPY --from=build /go/bin/wazuh-agent-autoadd /usr/local/bin/
COPY init_wazuh_agent.sh .
RUN chmod 755 /init_wazuh_agent.sh
ENTRYPOINT ["/init_wazuh_agent.sh"]