Skip to content

Commit 2d4f4be

Browse files
committed
Add airstack build command for docker compose build
1 parent 2eee261 commit 2d4f4be

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

airstack.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,59 @@ function cmd_up {
740740
log_info "Services brought up successfully"
741741
}
742742

743+
function cmd_build {
744+
check_docker
745+
746+
local env_files=()
747+
local other_args=()
748+
749+
# Convert arguments to array for easier processing
750+
local args=("$@")
751+
local i=0
752+
753+
while [ $i -lt ${#args[@]} ]; do
754+
local arg="${args[$i]}"
755+
756+
if [[ "$arg" == "--env-file" ]]; then
757+
# Get the next argument as the env file path
758+
i=$((i+1))
759+
if [ $i -lt ${#args[@]} ]; then
760+
env_files+=("--env-file" "${args[$i]}")
761+
else
762+
log_error "Missing value for --env-file argument"
763+
return 1
764+
fi
765+
elif [[ "$arg" == "--env-file="* ]]; then
766+
# Handle --env-file=path format
767+
env_files+=("$arg")
768+
else
769+
other_args+=("$arg")
770+
fi
771+
772+
i=$((i+1))
773+
done
774+
775+
# Build compose arguments array
776+
local compose_args=("-f" "$PROJECT_ROOT/docker-compose.yaml")
777+
778+
# Add all env files
779+
for env_file in "${env_files[@]}"; do
780+
compose_args+=("$env_file")
781+
done
782+
783+
# Add the 'build' command
784+
compose_args+=("build")
785+
786+
# Add service names and other arguments
787+
if [ ${#other_args[@]} -gt 0 ]; then
788+
compose_args+=("${other_args[@]}")
789+
fi
790+
791+
log_info "Building services with containerized docker-compose..."
792+
run_docker_compose "${compose_args[@]}"
793+
log_info "Build completed successfully"
794+
}
795+
743796
function cmd_down {
744797
check_docker
745798

@@ -991,6 +1044,7 @@ declare -A COMMAND_HELP
9911044
function register_builtin_commands {
9921045
COMMANDS["install"]="cmd_install"
9931046
COMMANDS["setup"]="cmd_setup"
1047+
COMMANDS["build"]="cmd_build"
9941048
COMMANDS["up"]="cmd_up"
9951049
COMMANDS["down"]="cmd_down"
9961050
COMMANDS["connect"]="cmd_connect"
@@ -1004,6 +1058,7 @@ function register_builtin_commands {
10041058
# Register help text for built-in commands
10051059
COMMAND_HELP["install"]="Install dependencies (Docker Engine, NVIDIA Container Toolkit)"
10061060
COMMAND_HELP["setup"]="Configure AirStack settings and add to shell profile"
1061+
COMMAND_HELP["build"]="Build or rebuild Docker Compose service images"
10071062
COMMAND_HELP["up"]="Start services using Docker Compose"
10081063
COMMAND_HELP["down"]="down services"
10091064
COMMAND_HELP["connect"]="Connect to a running container (supports partial name matching)"

0 commit comments

Comments
 (0)