Change UID user on build stage

This commit is contained in:
Victor Carlos Erenu
2026-05-13 21:23:26 +07:00
parent 6b9e2fbfb3
commit a70b0bd492
5 changed files with 76 additions and 12 deletions
+16 -3
View File
@@ -14,8 +14,21 @@ ARG WAZUH_AGENT_NAME='CHANGE_AGENT_NAME'
ARG TARGETARCH
ARG wazuh_agent_x86_64_rpm
ARG wazuh_agent_aarch64_rpm
ARG WAZUH_UID=101
ARG WAZUH_GID=101
RUN RPM_ARCH="x86_64" && \
# Install only runtime dependencies
RUN dnf install procps shadow-utils -y && \
dnf clean all && \
getent group wazuh || groupadd -r -g ${WAZUH_GID} wazuh && \
getent passwd wazuh || useradd --system \
--no-create-home \
--home-dir /var/ossec \
--uid ${WAZUH_UID} \
--gid ${WAZUH_GID} \
--shell /sbin/nologin \
wazuh && \
RPM_ARCH="x86_64" && \
if [ "${TARGETARCH}" = "arm64" ]; then RPM_ARCH="aarch64"; fi && \
URL_VAR="wazuh_agent_${RPM_ARCH}_rpm" && \
agent_url="${!URL_VAR}" && \
@@ -56,10 +69,10 @@ RUN dnf install procps shadow-utils -y && \
wazuh
# Copy Wazuh Agent installation from builder
COPY --from=builder --chown=${WAZUH_UID}:${WAZUH_GID} /var/ossec /var/ossec
COPY --from=builder /var/ossec /var/ossec
# Copy tini static binary
COPY --from=builder --chown=${WAZUH_UID}:${WAZUH_GID} /usr/local/bin/tini /usr/local/bin/tini
COPY --from=builder /usr/local/bin/tini /usr/local/bin/tini
# Copy entrypoint and init scripts
COPY config/entrypoint.sh /entrypoint.sh