#!/bin/bash

set -e

if command -v podman-compose >/dev/null 2>&1; then
    COMPOSE_CMD="podman-compose"
    export CONTAINER_SOCKET_PATH="${XDG_RUNTIME_DIR:-/run/user/$UID}/podman/podman.sock"
else
    COMPOSE_CMD="docker-compose"
    USER_PODMAN_SOCKET_PATH=/run/user/$UID/podman/podman.sock
    export CONTAINER_SOCKET_PATH="$USER_PODMAN_SOCKET_PATH"

    if [ -e "$USER_PODMAN_SOCKET_PATH" ]; then
        export DOCKER_HOST="unix://$USER_PODMAN_SOCKET_PATH"
    fi
fi

BUILDKIT_PROGRESS=plain $COMPOSE_CMD --file docs/docker-compose.yaml up --build --force-recreate
