forked from wazuh/wazuh-docker
Merge pull request #2183 from wazuh/enh/2172-Improve_S3_artifact_URLs_handling
Improve S3 artifact URLs handling
This commit is contained in:
@@ -20,10 +20,10 @@ on:
|
||||
description: 'Package revision'
|
||||
default: '1'
|
||||
required: true
|
||||
reference:
|
||||
description: 'Dev reference'
|
||||
commit_list:
|
||||
description: 'Wazuh components revisions (comma-separated string list) ["indexer", "manager", "dashboard", "agent"]'
|
||||
type: string
|
||||
default: latest
|
||||
default: '["latest", "latest", "latest", "latest"]'
|
||||
id:
|
||||
description: "ID used to identify the workflow uniquely."
|
||||
type: string
|
||||
@@ -54,10 +54,10 @@ on:
|
||||
default: '1'
|
||||
required: true
|
||||
type: string
|
||||
reference:
|
||||
description: 'Dev reference'
|
||||
commit_list:
|
||||
description: 'Wazuh components revisions (comma-separated string list) ["indexer", "manager", "dashboard", "agent"]'
|
||||
type: string
|
||||
default: latest
|
||||
default: '["latest", "latest", "latest", "latest"]'
|
||||
id:
|
||||
description: "ID used to identify the workflow uniquely."
|
||||
type: string
|
||||
@@ -68,16 +68,17 @@ on:
|
||||
default: false
|
||||
required: false
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
setup:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
|
||||
outputs:
|
||||
WAZUH_COMPONENTS: ${{ steps.compute-outputs.outputs.WAZUH_COMPONENTS }}
|
||||
COMMIT_LIST: ${{ steps.compute-outputs.outputs.COMMIT_LIST }}
|
||||
|
||||
steps:
|
||||
- name: Print inputs
|
||||
@@ -96,7 +97,7 @@ jobs:
|
||||
echo "* products: ${{ inputs.products }}"
|
||||
echo "* revision: ${{ inputs.revision }}"
|
||||
echo "* dev: ${{ inputs.dev }}"
|
||||
echo "* dev reference: ${{ inputs.reference }}"
|
||||
echo "* commit_list: ${{ inputs.commit_list }}"
|
||||
echo "---------------------------------------------"
|
||||
|
||||
- name: Set up variables
|
||||
@@ -118,15 +119,169 @@ jobs:
|
||||
echo "WAZUH_COMPONENTS=[\"wazuh-manager\",\"wazuh-dashboard\",\"wazuh-indexer\",\"wazuh-agent\"]" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
# Set REVISIONS
|
||||
if [[ "${{ inputs.commit_list }}" != "null" && "${{ inputs.commit_list }}" != "" ]]; then
|
||||
COMMIT_LIST='${{ inputs.commit_list }}'
|
||||
else
|
||||
COMMIT_LIST='["latest", "latest", "latest", "latest"]'
|
||||
fi
|
||||
echo "COMMIT_LIST=$COMMIT_LIST" >> $GITHUB_OUTPUT
|
||||
echo "Revision list (indexer, manager, dashboard, agent): $COMMIT_LIST"
|
||||
|
||||
package-urls:
|
||||
name: generate package urls
|
||||
runs-on: ubuntu-22.04
|
||||
needs: setup
|
||||
|
||||
env:
|
||||
ARTIFACT_URLS_FILE_TEMP: "/tmp/wazuh-docker/artifact_urls.yml"
|
||||
|
||||
steps:
|
||||
- name: Configure AWS credentials
|
||||
if: ${{ inputs.dev == true }}
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
role-to-assume: ${{ secrets.AWS_IAM_DOCKER_ROLE }}
|
||||
aws-region: ${{ secrets.AWS_REGION }}
|
||||
|
||||
- name: Download S3 package URIs file (if applicable)
|
||||
if: ${{ inputs.dev == true }}
|
||||
run: |
|
||||
mkdir -p "$(dirname "$ARTIFACT_URLS_FILE_TEMP")"
|
||||
|
||||
# Download the S3 package URIs file
|
||||
S3_BUCKET="${{ secrets.ARTIFACTS_S3_BUCKET }}"
|
||||
S3_KEY="deployment/artifact_urls.yml"
|
||||
aws s3 cp "s3://$S3_BUCKET/$S3_KEY" "$ARTIFACT_URLS_FILE_TEMP" --region us-west-1
|
||||
|
||||
# Verify the file was downloaded
|
||||
if [ -f "$ARTIFACT_URLS_FILE_TEMP" ]; then
|
||||
echo "S3 package URIs file downloaded successfully."
|
||||
else
|
||||
echo "Failed to download S3 package URIs file." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Generate the variables file (signing each package URI)
|
||||
if: ${{ inputs.dev == true }}
|
||||
run: |
|
||||
# Define necessary variables
|
||||
WAZUH_VERSION_RAW="${{ inputs.image_tag }}"
|
||||
WAZUH_VERSION="${WAZUH_VERSION_RAW%%-*}"
|
||||
WAZUH_MAJOR="${WAZUH_VERSION%%.*}"
|
||||
COMMIT_LIST='${{ needs.setup.outputs.COMMIT_LIST }}'
|
||||
|
||||
OUTPUT_FILE="/tmp/wazuh-docker/artifact_urls_processed.yml"
|
||||
PRESIGNED_OUTPUT_FILE="/tmp/wazuh-docker/artifact_urls_presigned.yml"
|
||||
|
||||
mkdir -p "$(dirname "$OUTPUT_FILE")"
|
||||
|
||||
: > "$OUTPUT_FILE"
|
||||
: > "$PRESIGNED_OUTPUT_FILE"
|
||||
|
||||
# Extract revisions using jq
|
||||
INDEXER_COMMIT=$(echo "$COMMIT_LIST" | jq -r '.[0]')
|
||||
MANAGER_COMMIT=$(echo "$COMMIT_LIST" | jq -r '.[1]')
|
||||
DASHBOARD_COMMIT=$(echo "$COMMIT_LIST" | jq -r '.[2]')
|
||||
AGENT_COMMIT=$(echo "$COMMIT_LIST" | jq -r '.[3]')
|
||||
|
||||
# Verify if the input file exists
|
||||
if [ ! -f "$ARTIFACT_URLS_FILE_TEMP" ]; then
|
||||
echo "The input file $ARTIFACT_URLS_FILE_TEMP does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Process the file line by line (replacing ocurrences)
|
||||
while IFS= read -r line || [ -n "$line" ]; do
|
||||
# Skip empty lines and comments
|
||||
if [[ -z "$line" || "$line" =~ ^[[:space:]]*# ]]; then
|
||||
echo "$line" >> "$OUTPUT_FILE"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Replace variables with their actual values
|
||||
line=${line//\$\{\{ vars.AWS_S3_BUCKET_DEV \}\}/${{ vars.AWS_S3_BUCKET_DEV }}}
|
||||
line=${line//\$\{\{ env.MAJOR \}\}/$WAZUH_MAJOR}
|
||||
line=${line//\$\{\{ env.WAZUH_VERSION \}\}/$WAZUH_VERSION}
|
||||
|
||||
# Replace component revisions
|
||||
line=${line//\$\{\{ env.INDEXER_REVISION \}\}/$INDEXER_COMMIT}
|
||||
line=${line//\$\{\{ env.MANAGER_REVISION \}\}/$MANAGER_COMMIT}
|
||||
line=${line//\$\{\{ env.DASHBOARD_REVISION \}\}/$DASHBOARD_COMMIT}
|
||||
line=${line//\$\{\{ env.AGENT_REVISION \}\}/$AGENT_COMMIT}
|
||||
|
||||
# Append the processed line to the output file
|
||||
echo "$line" >> "$OUTPUT_FILE"
|
||||
done < "$ARTIFACT_URLS_FILE_TEMP"
|
||||
|
||||
# Verify the output file
|
||||
if [ -f "$OUTPUT_FILE" ]; then
|
||||
echo "The downloaded file artifact_urls.yml was successfully processed at $OUTPUT_FILE."
|
||||
else
|
||||
echo "Failed to create processed artifact_urls.yml file." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Generate the presigned URLs for each package
|
||||
while IFS= read -r line || [ -n "$line" ]; do
|
||||
# Skip empty lines and comments
|
||||
if [[ -z "$line" || "$line" =~ ^[[:space:]]*# ]]; then
|
||||
echo "$line" >> "$PRESIGNED_OUTPUT_FILE"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Extract both package_name and package_s3_uri from the line
|
||||
if [[ "$line" =~ ^([a-zA-Z0-9_]+):[[:space:]]*\"?s3://([^\"[:space:]]+) ]]; then
|
||||
PACKAGE_NAME="${BASH_REMATCH[1]}"
|
||||
PACKAGE_S3_URI="s3://${BASH_REMATCH[2]}"
|
||||
|
||||
# Check if the object exists in S3
|
||||
BUCKET_NAME=$(echo "$PACKAGE_S3_URI" | cut -d '/' -f 3)
|
||||
OBJ_KEY=$(echo "$PACKAGE_S3_URI" | cut -d '/' -f 4-)
|
||||
if ! aws s3api head-object --bucket "$BUCKET_NAME" --key "$OBJ_KEY" --region us-west-1 > /dev/null 2>&1; then
|
||||
echo "Object $PACKAGE_S3_URI does not exist. Skipping..." >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
# Generate a pre-signed URL for the S3 URI
|
||||
echo "Generating pre-signed URL for $PACKAGE_NAME..."
|
||||
PRESIGNED_URL=$(aws s3 presign "$PACKAGE_S3_URI" --expires-in 43200 --region us-west-1)
|
||||
presigned_url_line="$PACKAGE_NAME: \"$PRESIGNED_URL\""
|
||||
|
||||
# Append the processed line to the output file
|
||||
echo "$presigned_url_line" >> "$PRESIGNED_OUTPUT_FILE"
|
||||
else
|
||||
echo "$line" >> "$PRESIGNED_OUTPUT_FILE"
|
||||
|
||||
echo "Skipping line for presigning (no S3 URI found):"
|
||||
echo "$line"
|
||||
fi
|
||||
done < "$OUTPUT_FILE"
|
||||
|
||||
# Verify the presigned urls file
|
||||
if [ -f "$PRESIGNED_OUTPUT_FILE" ]; then
|
||||
echo "Presigned URLs file created successfully at $PRESIGNED_OUTPUT_FILE."
|
||||
else
|
||||
echo "Failed to create presigned artifact_urls.yml file." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Also store the final file as the name expected by build-images.sh
|
||||
cp "$PRESIGNED_OUTPUT_FILE" artifact_urls.yml
|
||||
|
||||
- name: Save presigned URLs file to artifact
|
||||
if: ${{ inputs.dev == true }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: presigned-artifact-urls-${{ github.run_id }}
|
||||
path: artifact_urls.yml
|
||||
|
||||
build-and-push:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
|
||||
needs:
|
||||
- setup
|
||||
- package-urls
|
||||
|
||||
strategy:
|
||||
fail-fast: false # all jobs will run even if one fails
|
||||
@@ -144,9 +299,6 @@ jobs:
|
||||
with:
|
||||
ref: ${{ inputs.docker_reference }}
|
||||
|
||||
- name: free disk space
|
||||
uses: ./.github/free-disk-space
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
@@ -171,36 +323,16 @@ jobs:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Create artifact_urls.yml file
|
||||
if : ${{ inputs.dev == true }}
|
||||
run: |
|
||||
cat << EOF > artifact_urls.yml
|
||||
wazuh_manager_url_amd64_deb: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-manager_5.0.0-${{ inputs.reference }}_amd64.deb --expires-in 3600 --region us-west-1)"
|
||||
wazuh_manager_url_arm64_deb: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-manager_5.0.0-${{ inputs.reference }}_arm64.deb --expires-in 3600 --region us-west-1)"
|
||||
wazuh_manager_url_x86_64_rpm: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-manager-5.0.0-${{ inputs.reference }}.x86_64.rpm --expires-in 3600 --region us-west-1)"
|
||||
wazuh_manager_url_aarch64_rpm: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-manager-5.0.0-${{ inputs.reference }}.aarch64.rpm --expires-in 3600 --region us-west-1)"
|
||||
wazuh_indexer_url_amd64_deb: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-indexer_5.0.0-${{ inputs.reference }}_amd64.deb --expires-in 3600 --region us-west-1)"
|
||||
wazuh_indexer_url_arm64_deb: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-indexer_5.0.0-${{ inputs.reference }}_arm64.deb --expires-in 3600 --region us-west-1)"
|
||||
wazuh_indexer_url_x86_64_rpm: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-indexer-5.0.0-${{ inputs.reference }}.x86_64.rpm --expires-in 3600 --region us-west-1)"
|
||||
wazuh_indexer_url_aarch64_rpm: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-indexer-5.0.0-${{ inputs.reference }}.aarch64.rpm --expires-in 3600 --region us-west-1)"
|
||||
wazuh_dashboard_url_amd64_deb: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-dashboard_5.0.0-${{ inputs.reference }}_amd64.deb --expires-in 3600 --region us-west-1)"
|
||||
wazuh_dashboard_url_arm64_deb: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-dashboard_5.0.0-${{ inputs.reference }}_arm64.deb --expires-in 3600 --region us-west-1)"
|
||||
wazuh_dashboard_url_x86_64_rpm: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-dashboard-5.0.0-${{ inputs.reference }}.x86_64.rpm --expires-in 3600 --region us-west-1)"
|
||||
wazuh_dashboard_url_aarch64_rpm: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-dashboard-5.0.0-${{ inputs.reference }}.aarch64.rpm --expires-in 3600 --region us-west-1)"
|
||||
wazuh_agent_url_amd64_deb: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-agent_5.0.0-${{ inputs.reference }}_amd64.deb --expires-in 3600 --region us-west-1)"
|
||||
wazuh_agent_url_arm64_deb: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-agent_5.0.0-${{ inputs.reference }}_arm64.deb --expires-in 3600 --region us-west-1)"
|
||||
wazuh_agent_url_x86_64_rpm: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-agent-5.0.0-${{ inputs.reference }}.x86_64.rpm --expires-in 3600 --region us-west-1)"
|
||||
wazuh_agent_url_aarch64_rpm: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-agent-5.0.0-${{ inputs.reference }}.aarch64.rpm --expires-in 3600 --region us-west-1)"
|
||||
wazuh_agent_url_i386_msi: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-agent-5.0.0-${{ inputs.reference }}.i386.msi --expires-in 3600 --region us-west-1)"
|
||||
wazuh_agent_url_intel64_pkg: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-agent-5.0.0-${{ inputs.reference }}.intel64.pkg --expires-in 3600 --region us-west-1)"
|
||||
wazuh_agent_url_arm64_pkg: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/main/packages/wazuh-agent-5.0.0-${{ inputs.reference }}.arm64.pkg --expires-in 3600 --region us-west-1)"
|
||||
wazuh_certs_tool: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/secondary/installation-assistant/5.0.0/wazuh-certs-tool.sh --expires-in 3600 --region us-west-1)"
|
||||
wazuh_config_yml: "$(aws s3 presign s3://${{ vars.AWS_S3_BUCKET_DEV }}/development/wazuh/5.x/secondary/installation-assistant/5.0.0/config.yml --expires-in 3600 --region us-west-1)"
|
||||
EOF
|
||||
working-directory: ./build-docker-images
|
||||
- name: Download artifact_urls.yml (dev)
|
||||
if: ${{ inputs.dev == true }}
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: presigned-artifact-urls-${{ github.run_id }}
|
||||
path: ./build-docker-images
|
||||
|
||||
- name: Build Wazuh images
|
||||
run: |
|
||||
COMMIT_LIST='${{ needs.setup.outputs.COMMIT_LIST }}'
|
||||
if [[ "$IMAGE_TAG" == *"-"* ]]; then
|
||||
IFS='-' read -r -a tokens <<< "$IMAGE_TAG"
|
||||
if [ -z "${tokens[1]}" ]; then
|
||||
@@ -210,13 +342,13 @@ jobs:
|
||||
DEV_STAGE=${tokens[1]}
|
||||
WAZUH_VER=${tokens[0]}
|
||||
if [ "${{ inputs.dev }}" = true ]; then
|
||||
./build-images.sh -v $WAZUH_VER -r $REVISION -d $DEV_STAGE -rg $IMAGE_REGISTRY -m -ref ${{ inputs.reference }} -c ${{ matrix.wazuh_component }}
|
||||
./build-images.sh -v $WAZUH_VER -r $REVISION -d $DEV_STAGE -rg $IMAGE_REGISTRY -m -refs "$COMMIT_LIST" -c ${{ matrix.wazuh_component }}
|
||||
else
|
||||
./build-images.sh -v $WAZUH_VER -r $REVISION -d $DEV_STAGE -rg $IMAGE_REGISTRY -m -c ${{ matrix.wazuh_component }}
|
||||
fi
|
||||
else
|
||||
if [ "${{ inputs.dev }}" = true ]; then
|
||||
./build-images.sh -v $IMAGE_TAG -r $REVISION -rg $IMAGE_REGISTRY -m -ref ${{ inputs.reference }} -c ${{ matrix.wazuh_component }}
|
||||
./build-images.sh -v $IMAGE_TAG -r $REVISION -rg $IMAGE_REGISTRY -m -refs "$COMMIT_LIST" -c ${{ matrix.wazuh_component }}
|
||||
else
|
||||
./build-images.sh -v $IMAGE_TAG -r $REVISION -rg $IMAGE_REGISTRY -m -c ${{ matrix.wazuh_component }}
|
||||
fi
|
||||
|
||||
@@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
### Changed
|
||||
|
||||
- Improve S3 artifact URLs handling ([#2183](https://github.com/wazuh/wazuh-docker/pull/2183))
|
||||
- Allow building separate targets ([#2177](https://github.com/wazuh/wazuh-docker/pull/2177))
|
||||
- Add developement option when tag name is only version without stage ([#2179](https://github.com/wazuh/wazuh-docker/pull/2179))
|
||||
- Add IMAGE_TAG stage reference ([#2178](https://github.com/wazuh/wazuh-docker/pull/2178))
|
||||
|
||||
@@ -19,7 +19,7 @@ WAZUH_REGISTRY=docker.io
|
||||
WAZUH_IMAGE_VERSION="5.0.0"
|
||||
WAZUH_TAG_REVISION="1"
|
||||
WAZUH_DEV_STAGE=""
|
||||
WAZUH_TAG_REFERENCE=""
|
||||
WAZUH_COMPONENTS_COMMIT_LIST='["latest", "latest", "latest", "latest"]'
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
@@ -63,26 +63,53 @@ build() {
|
||||
|
||||
awk -F':' '!/^#/ && NF>1 {name=$1; val=substr($0,length(name)+3); gsub(/[-.]/,"_",name); print name "=" val}' $ARTIFACT_URLS_FILE > artifacts_env.txt
|
||||
|
||||
if [ "${WAZUH_DEV_STAGE}" ];then
|
||||
if [ "${WAZUH_TAG_REFERENCE}" ];then
|
||||
IMAGE_TAG="${WAZUH_IMAGE_VERSION}-${WAZUH_DEV_STAGE,,}-${WAZUH_TAG_REFERENCE}"
|
||||
else
|
||||
IMAGE_TAG="${WAZUH_IMAGE_VERSION}-${WAZUH_DEV_STAGE,,}"
|
||||
fi
|
||||
else
|
||||
if [ "${WAZUH_TAG_REFERENCE}" ];then
|
||||
IMAGE_TAG="${WAZUH_IMAGE_VERSION}-${WAZUH_TAG_REFERENCE}"
|
||||
else
|
||||
IMAGE_TAG="${WAZUH_IMAGE_VERSION}"
|
||||
fi
|
||||
# Parse component commit list if provided
|
||||
if [ -n "${WAZUH_COMPONENTS_COMMIT_LIST}" ]; then
|
||||
# Extract individual commits from JSON array format: ["indexer", "manager", "dashboard", "agent"]
|
||||
INDEXER_COMMIT=$(echo "${WAZUH_COMPONENTS_COMMIT_LIST}" | grep -o '"[^"]*"' | sed -n '1p' | tr -d '"')
|
||||
MANAGER_COMMIT=$(echo "${WAZUH_COMPONENTS_COMMIT_LIST}" | grep -o '"[^"]*"' | sed -n '2p' | tr -d '"')
|
||||
DASHBOARD_COMMIT=$(echo "${WAZUH_COMPONENTS_COMMIT_LIST}" | grep -o '"[^"]*"' | sed -n '3p' | tr -d '"')
|
||||
AGENT_COMMIT=$(echo "${WAZUH_COMPONENTS_COMMIT_LIST}" | grep -o '"[^"]*"' | sed -n '4p' | tr -d '"')
|
||||
|
||||
echo "Component commits parsed:"
|
||||
echo " - Indexer: ${INDEXER_COMMIT}"
|
||||
echo " - Manager: ${MANAGER_COMMIT}"
|
||||
echo " - Dashboard: ${DASHBOARD_COMMIT}"
|
||||
echo " - Agent: ${AGENT_COMMIT}"
|
||||
elif [ -n "${WAZUH_DEV_STAGE}" ]; then
|
||||
echo "Error: Not found WAZUH_COMPONENTS_COMMIT_LIST." >&2
|
||||
clean 1
|
||||
fi
|
||||
|
||||
|
||||
# Function to get component-specific commit reference
|
||||
get_component_commit() {
|
||||
local component=$1
|
||||
case "${component}" in
|
||||
wazuh-indexer)
|
||||
echo "${INDEXER_COMMIT}"
|
||||
;;
|
||||
wazuh-manager)
|
||||
echo "${MANAGER_COMMIT}"
|
||||
;;
|
||||
wazuh-dashboard)
|
||||
echo "${DASHBOARD_COMMIT}"
|
||||
;;
|
||||
wazuh-agent)
|
||||
echo "${AGENT_COMMIT}"
|
||||
;;
|
||||
*)
|
||||
echo ""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Global env file (without IMAGE_TAG - will be component-specific)
|
||||
echo WAZUH_VERSION=$WAZUH_IMAGE_VERSION > ../.env
|
||||
echo WAZUH_IMAGE_VERSION=$WAZUH_IMAGE_VERSION >> ../.env
|
||||
echo WAZUH_TAG_REVISION=$WAZUH_TAG_REVISION >> ../.env
|
||||
echo WAZUH_UI_REVISION=$WAZUH_UI_REVISION >> ../.env
|
||||
echo WAZUH_REGISTRY=$WAZUH_REGISTRY >> ../.env
|
||||
echo IMAGE_TAG=$IMAGE_TAG >> ../.env
|
||||
|
||||
set -a
|
||||
source ../.env
|
||||
@@ -121,6 +148,14 @@ build() {
|
||||
for component in "${components_to_build[@]}"; do
|
||||
echo "Building ${component} image..."
|
||||
|
||||
# Get component-specific commit reference
|
||||
COMPONENT_COMMIT=$(get_component_commit "${component}")
|
||||
|
||||
# Generate component-specific IMAGE_TAG
|
||||
IMAGE_TAG="${WAZUH_IMAGE_VERSION}${WAZUH_DEV_STAGE:+-${WAZUH_DEV_STAGE,,}-${COMPONENT_COMMIT}}"
|
||||
echo "Using IMAGE_TAG: ${IMAGE_TAG} for ${component}"
|
||||
export IMAGE_TAG="$IMAGE_TAG"
|
||||
|
||||
# Build common args (used by all components)
|
||||
build_args=(
|
||||
-t "${WAZUH_REGISTRY}/wazuh/${component}:${IMAGE_TAG}"
|
||||
@@ -132,31 +167,31 @@ build() {
|
||||
case "${component}" in
|
||||
wazuh-indexer)
|
||||
build_args+=(
|
||||
--build-arg wazuh_indexer_url_amd64_rpm="${wazuh_indexer_url_x86_64_rpm}"
|
||||
--build-arg wazuh_indexer_url_arm64_rpm="${wazuh_indexer_url_aarch64_rpm}"
|
||||
--build-arg wazuh_indexer_amd64_rpm="${wazuh_indexer_amd64_rpm}"
|
||||
--build-arg wazuh_indexer_arm64_rpm="${wazuh_indexer_arm64_rpm}"
|
||||
--build-arg wazuh_certs_tool="${wazuh_certs_tool}"
|
||||
--build-arg wazuh_config_yml="${wazuh_config_yml}"
|
||||
)
|
||||
;;
|
||||
wazuh-manager)
|
||||
build_args+=(
|
||||
--build-arg wazuh_manager_url_amd64_rpm="${wazuh_manager_url_x86_64_rpm}"
|
||||
--build-arg wazuh_manager_url_arm64_rpm="${wazuh_manager_url_aarch64_rpm}"
|
||||
--build-arg wazuh_manager_amd64_rpm="${wazuh_manager_amd64_rpm}"
|
||||
--build-arg wazuh_manager_arm64_rpm="${wazuh_manager_arm64_rpm}"
|
||||
)
|
||||
;;
|
||||
wazuh-dashboard)
|
||||
build_args+=(
|
||||
--build-arg WAZUH_UI_REVISION="${WAZUH_UI_REVISION}"
|
||||
--build-arg wazuh_dashboard_url_amd64_rpm="${wazuh_dashboard_url_x86_64_rpm}"
|
||||
--build-arg wazuh_dashboard_url_arm64_rpm="${wazuh_dashboard_url_aarch64_rpm}"
|
||||
--build-arg wazuh_dashboard_amd64_rpm="${wazuh_dashboard_amd64_rpm}"
|
||||
--build-arg wazuh_dashboard_arm64_rpm="${wazuh_dashboard_arm64_rpm}"
|
||||
--build-arg wazuh_certs_tool="${wazuh_certs_tool}"
|
||||
--build-arg wazuh_config_yml="${wazuh_config_yml}"
|
||||
)
|
||||
;;
|
||||
wazuh-agent)
|
||||
build_args+=(
|
||||
--build-arg wazuh_agent_url_amd64_rpm="${wazuh_agent_url_x86_64_rpm}"
|
||||
--build-arg wazuh_agent_url_arm64_rpm="${wazuh_agent_url_aarch64_rpm}"
|
||||
--build-arg wazuh_agent_amd64_rpm="${wazuh_agent_amd64_rpm}"
|
||||
--build-arg wazuh_agent_arm64_rpm="${wazuh_agent_arm64_rpm}"
|
||||
)
|
||||
;;
|
||||
esac
|
||||
@@ -180,7 +215,7 @@ help() {
|
||||
echo
|
||||
echo " -d, --dev <ref> [Optional] Set the development stage you want to build, example rc2 or beta1, not used by default."
|
||||
echo " -r, --revision <rev> [Optional] Package revision. By default ${WAZUH_TAG_REVISION}"
|
||||
echo " -ref, --reference <ref> [Optional] Set the Wazuh reference to build development images. By default, the latest stable release."
|
||||
echo " -refs, --references <ref> [Optional] Set each Wazuh component reference to be build (indexer, manager, dasboard and agent). Only used for development builds. By default, using the latest release: ['latest', 'latest', 'latest', 'latest']"
|
||||
echo " -rg, --registry <reg> [Optional] Set the Docker registry to push the images."
|
||||
echo " -c, --component <comp> [Required] Set the Wazuh component to build. Accepted values: 'wazuh-indexer', 'wazuh-manager', 'wazuh-dashboard', 'wazuh-agent'."
|
||||
echo " -v, --version <ver> [Optional] Set the Wazuh version should be builded. By default, ${WAZUH_IMAGE_VERSION}."
|
||||
@@ -219,9 +254,9 @@ main() {
|
||||
help 1
|
||||
fi
|
||||
;;
|
||||
"-ref"|"--reference")
|
||||
"-refs"|"--references")
|
||||
if [ -n "${2}" ]; then
|
||||
WAZUH_TAG_REFERENCE="${2}"
|
||||
WAZUH_COMPONENTS_COMMIT_LIST="${2}"
|
||||
shift 2
|
||||
else
|
||||
help 1
|
||||
|
||||
@@ -6,8 +6,8 @@ services:
|
||||
args:
|
||||
WAZUH_VERSION: ${WAZUH_VERSION}
|
||||
WAZUH_TAG_REVISION: ${WAZUH_TAG_REVISION}
|
||||
wazuh_manager_url_amd64_rpm: ${wazuh_manager_url_x86_64_rpm}
|
||||
wazuh_manager_url_arm64_rpm: ${wazuh_manager_url_aarch64_rpm}
|
||||
wazuh_manager_amd64_rpm: ${wazuh_manager_amd64_rpm}
|
||||
wazuh_manager_arm64_rpm: ${wazuh_manager_arm64_rpm}
|
||||
wazuh_certs_tool: ${wazuh_certs_tool}
|
||||
wazuh_config_yml: ${wazuh_config_yml}
|
||||
image: ${WAZUH_REGISTRY}/wazuh/wazuh-manager:${IMAGE_TAG}
|
||||
@@ -37,8 +37,8 @@ services:
|
||||
args:
|
||||
WAZUH_VERSION: ${WAZUH_VERSION}
|
||||
WAZUH_TAG_REVISION: ${WAZUH_TAG_REVISION}
|
||||
wazuh_agent_url_amd64_rpm: ${wazuh_agent_url_x86_64_rpm}
|
||||
wazuh_agent_url_arm64_rpm: ${wazuh_agent_url_aarch64_rpm}
|
||||
wazuh_agent_amd64_rpm: ${wazuh_agent_amd64_rpm}
|
||||
wazuh_agent_arm64_rpm: ${wazuh_agent_arm64_rpm}
|
||||
image: ${WAZUH_REGISTRY}/wazuh/wazuh-agent:${IMAGE_TAG}
|
||||
hostname: wazuh.agent
|
||||
restart: always
|
||||
@@ -49,8 +49,8 @@ services:
|
||||
args:
|
||||
WAZUH_VERSION: ${WAZUH_VERSION}
|
||||
WAZUH_TAG_REVISION: ${WAZUH_TAG_REVISION}
|
||||
wazuh_indexer_url_amd64_rpm: ${wazuh_indexer_url_x86_64_rpm}
|
||||
wazuh_indexer_url_arm64_rpm: ${wazuh_indexer_url_aarch64_rpm}
|
||||
wazuh_indexer_amd64_rpm: ${wazuh_indexer_amd64_rpm}
|
||||
wazuh_indexer_arm64_rpm: ${wazuh_indexer_arm64_rpm}
|
||||
wazuh_certs_tool: ${wazuh_certs_tool}
|
||||
wazuh_config_yml: ${wazuh_config_yml}
|
||||
image: ${WAZUH_REGISTRY}/wazuh/wazuh-indexer:${IMAGE_TAG}
|
||||
@@ -75,8 +75,8 @@ services:
|
||||
WAZUH_VERSION: ${WAZUH_VERSION}
|
||||
WAZUH_TAG_REVISION: ${WAZUH_TAG_REVISION}
|
||||
WAZUH_UI_REVISION: ${WAZUH_UI_REVISION}
|
||||
wazuh_dashboard_url_amd64_rpm: ${wazuh_dashboard_url_x86_64_rpm}
|
||||
wazuh_dashboard_url_arm64_rpm: ${wazuh_dashboard_url_aarch64_rpm}
|
||||
wazuh_dashboard_amd64_rpm: ${wazuh_dashboard_amd64_rpm}
|
||||
wazuh_dashboard_arm64_rpm: ${wazuh_dashboard_arm64_rpm}
|
||||
wazuh_certs_tool: ${wazuh_certs_tool}
|
||||
wazuh_config_yml: ${wazuh_config_yml}
|
||||
image: ${WAZUH_REGISTRY}/wazuh/wazuh-dashboard:${IMAGE_TAG}
|
||||
|
||||
@@ -13,10 +13,10 @@ ARG WAZUH_REGISTRATION_PORT='CHANGE_ENROLL_PORT'
|
||||
ARG WAZUH_AGENT_NAME='CHANGE_AGENT_NAME'
|
||||
ARG WAZUH_AGENT_GROUPS='CHANGE_AGENT_GROUPS'
|
||||
ARG TARGETARCH
|
||||
ARG wazuh_agent_url_amd64_rpm
|
||||
ARG wazuh_agent_url_arm64_rpm
|
||||
ARG wazuh_agent_amd64_rpm
|
||||
ARG wazuh_agent_arm64_rpm
|
||||
|
||||
RUN URL_VAR="wazuh_agent_url_${TARGETARCH}_rpm" && \
|
||||
RUN URL_VAR="wazuh_agent_${TARGETARCH}_rpm" && \
|
||||
agent_url="${!URL_VAR}" && \
|
||||
dnf install curl-minimal tar gzip procps -y &&\
|
||||
curl -o /wazuh-agent.rpm "${agent_url}" && \
|
||||
|
||||
@@ -6,12 +6,12 @@ ARG WAZUH_TAG_REVISION
|
||||
ARG WAZUH_UI_REVISION
|
||||
ARG INSTALL_DIR=/usr/share/wazuh-dashboard
|
||||
ARG TARGETARCH
|
||||
ARG wazuh_dashboard_url_amd64_rpm
|
||||
ARG wazuh_dashboard_url_arm64_rpm
|
||||
ARG wazuh_dashboard_amd64_rpm
|
||||
ARG wazuh_dashboard_arm64_rpm
|
||||
ARG wazuh_config_yml
|
||||
|
||||
# Update and install dependencies
|
||||
RUN URL_VAR="wazuh_dashboard_url_${TARGETARCH}_rpm" && \
|
||||
RUN URL_VAR="wazuh_dashboard_${TARGETARCH}_rpm" && \
|
||||
dashboard_url="${!URL_VAR}" && \
|
||||
dnf install curl-minimal libcap openssl -y && \
|
||||
curl -o /wazuh-dashboard.rpm "${dashboard_url}" && \
|
||||
|
||||
@@ -4,14 +4,14 @@ FROM amazonlinux:2023 AS builder
|
||||
ARG WAZUH_VERSION
|
||||
ARG WAZUH_TAG_REVISION
|
||||
ARG TARGETARCH
|
||||
ARG wazuh_indexer_url_amd64_rpm
|
||||
ARG wazuh_indexer_url_arm64_rpm
|
||||
ARG wazuh_indexer_amd64_rpm
|
||||
ARG wazuh_indexer_arm64_rpm
|
||||
ARG wazuh_certs_tool
|
||||
ARG wazuh_config_yml
|
||||
|
||||
COPY config/config.sh .
|
||||
|
||||
RUN URL_VAR="wazuh_indexer_url_${TARGETARCH}_rpm" && \
|
||||
RUN URL_VAR="wazuh_indexer_${TARGETARCH}_rpm" && \
|
||||
indexer_url="${!URL_VAR}" && \
|
||||
dnf install curl-minimal openssl xz tar findutils shadow-utils -y &&\
|
||||
curl -o /wazuh-indexer.rpm "${indexer_url}" && \
|
||||
|
||||
@@ -7,10 +7,10 @@ ARG WAZUH_VERSION
|
||||
ARG WAZUH_TAG_REVISION
|
||||
ARG S6_VERSION="v2.2.0.3"
|
||||
ARG TARGETARCH
|
||||
ARG wazuh_manager_url_amd64_rpm
|
||||
ARG wazuh_manager_url_arm64_rpm
|
||||
ARG wazuh_manager_amd64_rpm
|
||||
ARG wazuh_manager_arm64_rpm
|
||||
|
||||
RUN URL_VAR="wazuh_manager_url_${TARGETARCH}_rpm" && \
|
||||
RUN URL_VAR="wazuh_manager_${TARGETARCH}_rpm" && \
|
||||
manager_url="${!URL_VAR}" && \
|
||||
dnf install curl-minimal xz gnupg tar gzip openssl findutils procps -y &&\
|
||||
dnf clean all && \
|
||||
|
||||
@@ -31,7 +31,7 @@ Usage: build-images.sh [OPTIONS]
|
||||
|
||||
-d, --dev <ref> [Optional] Set the development stage you want to build, example rc2 or beta1, not used by default.
|
||||
-r, --revision <rev> [Optional] Package revision. By default 1
|
||||
-ref, --reference <ref> [Optional] Set the Wazuh reference to build development images. By default, the latest stable release.
|
||||
-refs, --references <ref> [Optional] Set each Wazuh component reference to be build (indexer, manager, dasboard and agent). By default, using the latest release: ['latest', 'latest', 'latest', 'latest']
|
||||
-rg, --registry <reg> [Optional] Set the Docker registry to push the images.
|
||||
-v, --version <ver> [Optional] Set the Wazuh version should be builded. By default, 5.0.0.
|
||||
-m, --multiarch [Optional] Enable multi-architecture builds.
|
||||
|
||||
Reference in New Issue
Block a user