Skip to content

Commit

Permalink
Add version definition on each RUN step
Browse files Browse the repository at this point in the history
  • Loading branch information
QU3B1M committed Nov 25, 2024
1 parent 1872bac commit ed6ea6d
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions docker/builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ RUN git clone --branch ${INDEXER_BRANCH} https://github.com/wazuh/wazuh-indexer
git clone --branch ${INDEXER_PLUGINS_BRANCH} https://github.com/wazuh/wazuh-indexer-plugins --depth 1 /opt/wazuh-indexer-plugins && \
git clone --branch ${INDEXER_REPORTING_BRANCH} https://github.com/wazuh/wazuh-indexer-reporting --depth 1 /opt/wazuh-indexer-reporting

# Set version env var
ENV VERSION=$(</opt/wazuh-indexer/VERSION)

# Install OpenJDK 21
RUN wget -O- https://download.java.net/openjdk/jdk21/ri/openjdk-21+35_linux-x64_bin.tar.gz | tar xz -C /opt/

Expand All @@ -88,12 +85,10 @@ RUN wget https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.

# Set GRADLE_HOME environment variable
ENV GRADLE_HOME=/opt/gradle/gradle-${GRADLE_VERSION}
ENV PATH=$GRADLE_HOME/bin:$PATH
ENV PATH=$GRADLE_HOME/bin/$PATH

## Copy build scripts to /opt directory only if build_scripts_dir is set.
#RUN if [ -n "${BUILD_SCRIPTS_DIR}" ]; then \
# cp -r ${BUILD_SCRIPTS_DIR} /opt/wazuh-indexer/build-scripts/; \
#fi
# Create the artifacts directory
RUN mkdir -p /opt/wazuh-indexer/artifacts/plugins

# Clean up APT when done
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
Expand All @@ -110,22 +105,30 @@ USER opensearchuser
# ---PACKAGE-BUILDING---

# Build plugins
RUN cd /opt/wazuh-indexer-plugins/plugins/setup && \
RUN export VERSION=$(cat /opt/wazuh-indexer/VERSION) && \
cd /opt/wazuh-indexer-plugins/plugins/setup && \
./gradlew build -Dversion=${VERSION} -Drevision=${REVISION} && \
cd /opt/wazuh-indexer-plugins/plugins/command-manager && \
./gradlew build -Dversion=${VERSION} -Drevision=${REVISION}

# Build reporting
RUN cd /opt/wazuh-indexer-reporting && \
RUN export VERSION=$(cat /opt/wazuh-indexer/VERSION) && \
cd /opt/wazuh-indexer-reporting && \
./gradlew build -Dversion=${VERSION} -Drevision=${REVISION}

# Copy builds
RUN cp /opt/wazuh-indexer-plugins/plugins/setup/build/distributions/wazuh-indexer-setup-${VERSION}.${REVISION}.zip /opt/wazuh-indexer/artifacts/plugins && \
cp /opt/wazuh-indexer-plugins/plugins/command-manager/build/distributions/wazuh-indexer-command-manager-${VERSION}.${REVISION}.zip /opt/wazuh-indexer/artifacts/plugins && \
cp /opt/wazuh-indexer-reporting/build/distributions/wazuh-indexer-reports-scheduler-${VERSION}.${REVISION}.zip /opt/wazuh-indexer/artifacts/plugins
# Copy builds /opt/wazuh-indexer/artifacts
RUN export VERSION=$(cat /opt/wazuh-indexer/VERSION) && \
cp /opt/wazuh-indexer-plugins/plugins/setup/build/distributions/wazuh-indexer-setup-${VERSION}.${REVISION}.zip /opt/wazuh-indexer/artifacts/plugins/ && \
cp /opt/wazuh-indexer-plugins/plugins/command-manager/build/distributions/wazuh-indexer-command-manager-${VERSION}.${REVISION}.zip /opt/wazuh-indexer/artifacts/plugins/ && \
cp /opt/wazuh-indexer-reporting/build/distributions/wazuh-indexer-reports-scheduler-${VERSION}.${REVISION}.zip /opt/wazuh-indexer/artifacts/plugins/

USER root

# Configure Git to trust the repositories' directories
RUN git config --global --add safe.directory /opt/wazuh-indexer-plugins && \
git config --global --add safe.directory /opt/wazuh-indexer-reporting && \
git config --global --add safe.directory /opt/wazuh-indexer \

# Combined RUN command
RUN cd /opt/wazuh-indexer-plugins && PLUGINS_HASH=$(git rev-parse --short HEAD) && \
cd /opt/wazuh-indexer-reporting && REPORTING_HASH=$(git rev-parse --short HEAD) && \
Expand Down

0 comments on commit ed6ea6d

Please sign in to comment.