fix: Improve Docker command handling and error messages in start_docker_build.sh
This commit is contained in:
@@ -9,7 +9,26 @@ if ! command -v docker >/dev/null 2>&1; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! docker compose version >/dev/null 2>&1; then
|
DOCKER_CMD=(docker)
|
||||||
|
|
||||||
|
if ! docker info >/dev/null 2>&1; then
|
||||||
|
if command -v sudo >/dev/null 2>&1 && sudo -n docker info >/dev/null 2>&1; then
|
||||||
|
DOCKER_CMD=(sudo docker)
|
||||||
|
echo "==> Docker daemon requires elevated permissions; using sudo docker"
|
||||||
|
else
|
||||||
|
echo "Error: cannot access Docker daemon (/var/run/docker.sock)."
|
||||||
|
echo ""
|
||||||
|
echo "Fix options:"
|
||||||
|
echo " 1) Run once with sudo: sudo ./start_docker_build.sh"
|
||||||
|
echo " 2) Permanent fix (recommended):"
|
||||||
|
echo " sudo usermod -aG docker $USER"
|
||||||
|
echo " newgrp docker"
|
||||||
|
echo " # or logout/login"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! "${DOCKER_CMD[@]}" compose version >/dev/null 2>&1; then
|
||||||
echo "Error: docker compose plugin is not available."
|
echo "Error: docker compose plugin is not available."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -22,13 +41,13 @@ echo " NUITKA_JOBS=${NUITKA_JOBS}"
|
|||||||
echo " NUITKA_LOW_MEMORY=${NUITKA_LOW_MEMORY}"
|
echo " NUITKA_LOW_MEMORY=${NUITKA_LOW_MEMORY}"
|
||||||
|
|
||||||
echo "==> Building website image (Nuitka standalone conversion runs in Dockerfile)"
|
echo "==> Building website image (Nuitka standalone conversion runs in Dockerfile)"
|
||||||
NUITKA_JOBS="$NUITKA_JOBS" NUITKA_LOW_MEMORY="$NUITKA_LOW_MEMORY" docker compose build website
|
NUITKA_JOBS="$NUITKA_JOBS" NUITKA_LOW_MEMORY="$NUITKA_LOW_MEMORY" "${DOCKER_CMD[@]}" compose build website
|
||||||
|
|
||||||
echo "==> Starting internal MongoDB + Website containers"
|
echo "==> Starting internal MongoDB + Website containers"
|
||||||
docker compose up -d
|
"${DOCKER_CMD[@]}" compose up -d
|
||||||
|
|
||||||
echo "==> Container status"
|
echo "==> Container status"
|
||||||
docker compose ps
|
"${DOCKER_CMD[@]}" compose ps
|
||||||
|
|
||||||
echo "Application is starting on: http://localhost:4999"
|
echo "Application is starting on: http://localhost:4999"
|
||||||
echo "Use: docker compose logs -f website"
|
echo "Use: docker compose logs -f website"
|
||||||
|
|||||||
Reference in New Issue
Block a user