feat : optional run backend on host for start_services.sh

This commit is contained in:
martin legrand
2025-05-29 10:51:08 +08:00
committed by Antoine Vivies
parent 819a3fb98d
commit abae98cf77
2 changed files with 34 additions and 26 deletions
+4
View File
@@ -3,6 +3,7 @@ version: '3'
services: services:
redis: redis:
container_name: redis container_name: redis
profiles: ["core", "full"]
image: docker.io/valkey/valkey:8-alpine image: docker.io/valkey/valkey:8-alpine
command: valkey-server --save 30 1 --loglevel warning command: valkey-server --save 30 1 --loglevel warning
restart: unless-stopped restart: unless-stopped
@@ -24,6 +25,7 @@ services:
searxng: searxng:
container_name: searxng container_name: searxng
profiles: ["core", "full"]
image: docker.io/searxng/searxng:latest image: docker.io/searxng/searxng:latest
restart: unless-stopped restart: unless-stopped
ports: ports:
@@ -51,6 +53,7 @@ services:
frontend: frontend:
container_name: frontend container_name: frontend
profiles: ["core", "full"]
build: build:
context: ./frontend context: ./frontend
dockerfile: Dockerfile.frontend dockerfile: Dockerfile.frontend
@@ -68,6 +71,7 @@ services:
backend: backend:
container_name: backend container_name: backend
profiles: ["backend", "full"]
build: build:
context: . context: .
dockerfile: Dockerfile.backend dockerfile: Dockerfile.backend
+17 -13
View File
@@ -90,16 +90,16 @@ sleep 4
docker stop $(docker ps -a -q) docker stop $(docker ps -a -q)
echo "All containers stopped" echo "All containers stopped"
# First start backend and wait for it to be healthy if [ "$1" = "full" ]; then
echo "Starting backend service..." # First start backend and wait for it to be healthy
if ! $COMPOSE_CMD up -d backend; then echo "Full docker deployement. Starting backend service..."
if ! $COMPOSE_CMD up -d backend; then
echo "Error: Failed to start backend container." echo "Error: Failed to start backend container."
exit 1 exit 1
fi fi
# Wait for backend to be healthy (check if it's running and not restarting)
# Wait for backend to be healthy (check if it's running and not restarting) echo "Waiting for backend to be ready..."
echo "Waiting for backend to be ready..." for i in {1..30}; do
for i in {1..30}; do
if [ "$(docker inspect -f '{{.State.Running}}' backend)" = "true" ] && \ if [ "$(docker inspect -f '{{.State.Running}}' backend)" = "true" ] && \
[ "$(docker inspect -f '{{.State.Restarting}}' backend)" = "false" ]; then [ "$(docker inspect -f '{{.State.Restarting}}' backend)" = "false" ]; then
echo "backend is ready!" echo "backend is ready!"
@@ -111,13 +111,17 @@ for i in {1..30}; do
exit 1 exit 1
fi fi
sleep 1 sleep 1
done done
if ! $COMPOSE_CMD --profile full up; then
# start remaining services for searxng, redis, frontend services
if ! $COMPOSE_CMD up; then
echo "Error: Failed to start containers. Check Docker logs with '$COMPOSE_CMD logs'." echo "Error: Failed to start containers. Check Docker logs with '$COMPOSE_CMD logs'."
echo "Possible fixes: Run with sudo or ensure port 8080 is free." echo "Possible fixes: Run with sudo or ensure port 8080 is free."
exit 1 exit 1
fi
else
if ! $COMPOSE_CMD --profile core up; then
echo "Error: Failed to start containers. Check Docker logs with '$COMPOSE_CMD logs'."
echo "Possible fixes: Run with sudo or ensure port 8080 is free."
exit 1
fi
fi fi
sleep 10 sleep 10