forked from wazuh/wazuh-docker
Merge pull request #2126 from wazuh/enh/2097-certsgen-imagebuild
Modify to build certs gen image
This commit is contained in:
@@ -1,9 +1,27 @@
|
||||
# Certificate creation image build
|
||||
# Certificate Creation Image Build
|
||||
|
||||
The dockerfile hosted in this directory is used to build the image used to boot Wazuh's single node and multi node stacks.
|
||||
The dockerfile hosted in this directory is used to build the image required for generating Wazuh Docker single-node and multi-node certificate files
|
||||
|
||||
To create the image, the following command must be executed:
|
||||
## Pre-requisites
|
||||
|
||||
### QEMU
|
||||
|
||||
Set up QEMU to enable building multi-architecture Docker images
|
||||
|
||||
Useful documentation:
|
||||
|
||||
- https://www.qemu.org/download/
|
||||
- https://docs.docker.com/build/building/multi-platform/#qemu
|
||||
|
||||
## Procedure
|
||||
|
||||
Run the following script to build the wazuh-certs-generator docker image
|
||||
|
||||
```console
|
||||
./build-image.sh -v <IMAGE_TAG> [-m] [-rg <REGISTRY>]
|
||||
```
|
||||
$ docker build -t wazuh/wazuh-certs-generator:0.0.3 .
|
||||
```
|
||||
|
||||
Replace <IMAGE_TAG> with the new image desired tag.
|
||||
Use the `-m` flag to build a multi-architecture image (supports both `amd64` and `arm64`)
|
||||
Use the `-rg <REGISTRY>` parameter to specify a custom Docker registry (default is Docker Hub)
|
||||
By default, the script will attempt to push the image to the registry and will only work if credentials are properly configured.
|
||||
|
||||
Executable
+102
@@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Wazuh package generator
|
||||
# Copyright (C) 2023, Wazuh Inc.
|
||||
#
|
||||
# This program is a free software; you can redistribute it
|
||||
# and/or modify it under the terms of the GNU General Public
|
||||
# License (version 2) as published by the FSF - Free Software
|
||||
# Foundation.
|
||||
|
||||
WAZUH_CERTS_IMAGE_VERSION="0.0.4"
|
||||
WAZUH_REGISTRY="docker.io"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
trap ctrl_c INT
|
||||
|
||||
clean() {
|
||||
exit_code=$1
|
||||
exit ${exit_code}
|
||||
}
|
||||
|
||||
ctrl_c() {
|
||||
clean 1
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
build() {
|
||||
IMAGE_TAG="${WAZUH_CERTS_IMAGE_VERSION}"
|
||||
|
||||
echo WAZUH_REGISTRY=$WAZUH_REGISTRY > .env
|
||||
echo IMAGE_TAG=$IMAGE_TAG >> .env
|
||||
|
||||
set -a
|
||||
source .env
|
||||
set +a
|
||||
|
||||
if [ "${MULTIARCH}" ]; then
|
||||
docker buildx bake --file build-image.yml \
|
||||
--set *.platform=linux/amd64,linux/arm64 \
|
||||
--no-cache || clean 1
|
||||
else
|
||||
docker buildx bake --file build-image.yml --no-cache || clean 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
help() {
|
||||
echo
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo
|
||||
echo " -v, --version <ver> [Optional] Set the image version. By default ${WAZUH_CERTS_IMAGE_VERSION}."
|
||||
echo " -rg, --registry <reg> [Optional] Set the Docker registry to push the images."
|
||||
echo " -m, --multiarch [Optional] Enable multi-architecture builds."
|
||||
echo " -h, --help Show this help."
|
||||
echo
|
||||
exit $1
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
main() {
|
||||
while [ -n "${1}" ]
|
||||
do
|
||||
case "${1}" in
|
||||
"-h"|"--help")
|
||||
help 0
|
||||
;;
|
||||
"-m"|"--multiarch")
|
||||
MULTIARCH="true"
|
||||
shift
|
||||
;;
|
||||
"-rg"|"--registry")
|
||||
if [ -n "${2}" ]; then
|
||||
WAZUH_REGISTRY="${2}"
|
||||
shift 2
|
||||
else
|
||||
help 1
|
||||
fi
|
||||
;;
|
||||
"-v"|"--version")
|
||||
if [ -n "$2" ]; then
|
||||
WAZUH_CERTS_IMAGE_VERSION="$2"
|
||||
shift 2
|
||||
else
|
||||
help 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
help 1
|
||||
esac
|
||||
done
|
||||
|
||||
build || clean 1
|
||||
|
||||
clean 0
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -0,0 +1,8 @@
|
||||
# Wazuh App Copyright (C) 2017, Wazuh Inc. (License GPLv2)
|
||||
services:
|
||||
wazuh.certs.generator:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: ${WAZUH_REGISTRY}/wazuh/wazuh-certs-generator:${IMAGE_TAG}
|
||||
hostname: wazuh-certs-generator
|
||||
Reference in New Issue
Block a user