Clean conflicting containers during core deploy
This commit is contained in:
@@ -15,7 +15,6 @@ export DOCKER_CONFIG="/tmp/.docker"
|
|||||||
mkdir -p "$DOCKER_CONFIG"
|
mkdir -p "$DOCKER_CONFIG"
|
||||||
|
|
||||||
DB_FILE="/opt/appfactory/data/appfactory/appfactory.db"
|
DB_FILE="/opt/appfactory/data/appfactory/appfactory.db"
|
||||||
|
|
||||||
SERVICE_DIR="$WORKSPACE_DIR/$SERVICE_NAME"
|
SERVICE_DIR="$WORKSPACE_DIR/$SERVICE_NAME"
|
||||||
DEPLOY_DIR="$APPFACTORY_DIR/deploy"
|
DEPLOY_DIR="$APPFACTORY_DIR/deploy"
|
||||||
|
|
||||||
@@ -144,6 +143,19 @@ run_step() {
|
|||||||
} >>"$STDOUT_FILE" 2>>"$STDERR_FILE"
|
} >>"$STDOUT_FILE" 2>>"$STDERR_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanup_conflicting_containers() {
|
||||||
|
local service="$1"
|
||||||
|
|
||||||
|
docker ps -a --format "{{.ID}} {{.Names}}" \
|
||||||
|
| awk -v svc="$service" '$2 == svc || $2 ~ ("_" svc "$") { print $1 }' \
|
||||||
|
| while read -r container_id; do
|
||||||
|
if [ -n "$container_id" ]; then
|
||||||
|
echo "Removing conflicting container: $container_id"
|
||||||
|
docker rm -f "$container_id" || true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
run_step "Updating source" bash -c "
|
run_step "Updating source" bash -c "
|
||||||
@@ -165,6 +177,11 @@ if [ "$RESULT" -eq 0 ]; then
|
|||||||
RESULT=$?
|
RESULT=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$RESULT" -eq 0 ]; then
|
||||||
|
run_step "Cleaning conflicting containers" cleanup_conflicting_containers "$SERVICE_NAME"
|
||||||
|
RESULT=$?
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$RESULT" -eq 0 ]; then
|
if [ "$RESULT" -eq 0 ]; then
|
||||||
run_step "Recreating container" bash -c "
|
run_step "Recreating container" bash -c "
|
||||||
cd '$DEPLOY_DIR'
|
cd '$DEPLOY_DIR'
|
||||||
|
|||||||
Reference in New Issue
Block a user