- Improvements working with the cloud, minio, graylog and some first bugfixing
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
# Exit on any error
|
||||
set -e
|
||||
|
||||
. ./docker_env_switch.sh dev
|
||||
|
||||
# Load environment variables
|
||||
source .env
|
||||
|
||||
@@ -15,10 +17,64 @@ TAG="latest"
|
||||
# Platforms to build for
|
||||
PLATFORMS="linux/amd64,linux/arm64"
|
||||
|
||||
# Function to build and push a service
|
||||
build_and_push_service() {
|
||||
# Default action
|
||||
ACTION="both"
|
||||
|
||||
# Default build options
|
||||
NO_CACHE=""
|
||||
PROGRESS=""
|
||||
DEBUG=""
|
||||
|
||||
# Function to display usage information
|
||||
usage() {
|
||||
echo "Usage: $0 [-b|-p] [--no-cache] [--progress=plain] [--debug] [service1 service2 ...]"
|
||||
echo " -b: Build only (for current platform)"
|
||||
echo " -p: Push only (multi-platform)"
|
||||
echo " --no-cache: Perform a clean build without using cache"
|
||||
echo " --progress=plain: Show detailed progress of the build"
|
||||
echo " --debug: Enable debug mode for the build"
|
||||
echo " If no option is provided, both build and push will be performed."
|
||||
echo " If no services are specified, all eveai_ services and nginx will be processed."
|
||||
}
|
||||
|
||||
# Parse command-line options
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-b)
|
||||
ACTION="build"
|
||||
shift
|
||||
;;
|
||||
-p)
|
||||
ACTION="push"
|
||||
shift
|
||||
;;
|
||||
--no-cache)
|
||||
NO_CACHE="--no-cache"
|
||||
shift
|
||||
;;
|
||||
--progress=plain)
|
||||
PROGRESS="--progress=plain"
|
||||
shift
|
||||
;;
|
||||
--debug)
|
||||
DEBUG="--debug"
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
echo "Unknown option: $1"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Function to build and/or push a service
|
||||
process_service() {
|
||||
local SERVICE="$1"
|
||||
echo "Building and pushing $SERVICE..."
|
||||
echo "Processing $SERVICE..."
|
||||
|
||||
# Extract the build context and dockerfile from the compose file
|
||||
CONTEXT=$(yq e ".services.$SERVICE.build.context" compose_dev.yaml)
|
||||
@@ -36,18 +92,56 @@ build_and_push_service() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Build and push
|
||||
docker buildx build \
|
||||
--platform "$PLATFORMS" \
|
||||
-t "$REGISTRY/$SERVICE:$TAG" \
|
||||
-f "$CONTEXT/$DOCKERFILE" \
|
||||
"$CONTEXT" \
|
||||
--push
|
||||
# Build and/or push based on ACTION
|
||||
if [ "$ACTION" = "build" ]; then
|
||||
echo "Building $SERVICE for current platform..."
|
||||
docker build \
|
||||
$NO_CACHE \
|
||||
$PROGRESS \
|
||||
$DEBUG \
|
||||
-t "$REGISTRY/$SERVICE:$TAG" \
|
||||
-f "$CONTEXT/$DOCKERFILE" \
|
||||
"$CONTEXT"
|
||||
elif [ "$ACTION" = "push" ]; then
|
||||
echo "Building and pushing $SERVICE for multiple platforms..."
|
||||
docker buildx build \
|
||||
$NO_CACHE \
|
||||
$PROGRESS \
|
||||
$DEBUG \
|
||||
--platform "$PLATFORMS" \
|
||||
-t "$REGISTRY/$SERVICE:$TAG" \
|
||||
-f "$CONTEXT/$DOCKERFILE" \
|
||||
"$CONTEXT" \
|
||||
--push
|
||||
else
|
||||
echo "Building $SERVICE for current platform..."
|
||||
docker build \
|
||||
$NO_CACHE \
|
||||
$PROGRESS \
|
||||
$DEBUG \
|
||||
-t "$REGISTRY/$SERVICE:$TAG" \
|
||||
-f "$CONTEXT/$DOCKERFILE" \
|
||||
"$CONTEXT"
|
||||
|
||||
echo "Building and pushing $SERVICE for multiple platforms..."
|
||||
docker buildx build \
|
||||
$NO_CACHE \
|
||||
$PROGRESS \
|
||||
$DEBUG \
|
||||
--platform "$PLATFORMS" \
|
||||
-t "$REGISTRY/$SERVICE:$TAG" \
|
||||
-f "$CONTEXT/$DOCKERFILE" \
|
||||
"$CONTEXT" \
|
||||
--push
|
||||
fi
|
||||
}
|
||||
|
||||
# If no arguments are provided, build all services
|
||||
# If no arguments are provided, process all services
|
||||
if [ $# -eq 0 ]; then
|
||||
mapfile -t SERVICES < <(yq e '.services | keys | .[]' compose_dev.yaml | grep -E '^(nginx|eveai_)')
|
||||
SERVICES=()
|
||||
while IFS= read -r line; do
|
||||
SERVICES+=("$line")
|
||||
done < <(yq e '.services | keys | .[]' compose_dev.yaml | grep -E '^(nginx|eveai_)')
|
||||
else
|
||||
SERVICES=("$@")
|
||||
fi
|
||||
@@ -65,10 +159,10 @@ docker buildx use eveai_builder
|
||||
# Loop through services
|
||||
for SERVICE in "${SERVICES[@]}"; do
|
||||
if [[ "$SERVICE" == "nginx" || "$SERVICE" == eveai_* ]]; then
|
||||
if build_and_push_service "$SERVICE"; then
|
||||
echo "Successfully built and pushed $SERVICE"
|
||||
if process_service "$SERVICE"; then
|
||||
echo "Successfully processed $SERVICE"
|
||||
else
|
||||
echo "Failed to build and push $SERVICE"
|
||||
echo "Failed to process $SERVICE"
|
||||
fi
|
||||
else
|
||||
echo "Skipping $SERVICE as it's not nginx or doesn't start with eveai_"
|
||||
|
||||
Reference in New Issue
Block a user