Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ clean: ## Clean up unused Docker resources
@docker volume prune -f
@echo "$(GREEN)Cleanup completed$(NC)"

health: ## Run comprehensive health diagnostics
@echo "$(BLUE)Running LazyVim environment health check...$(NC)"
@./scripts/health-check.sh

status: ## Show container status
@echo "$(BLUE)Container Status:$(NC)"
@CONTAINER_STATE=$$(docker inspect $(CONTAINER_NAME) 2>/dev/null | grep '"Status"' | cut -d'"' -f4 || echo "missing"); \
Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ lazyvim-docker/
├── docs/ # Documentation
│ ├── COMMANDS.md # Complete command reference
│ └── CHANGELOG.md # Version history
├── scripts/ # Internal scripts (use make commands instead)
├── scripts/ # Internal scripts (always use make commands instead)
│ ├── build.sh # Build script
│ ├── init.sh # Init script
│ ├── destroy.sh # Destroy script
Expand Down Expand Up @@ -160,16 +160,11 @@ lazyvim-docker/

```bash
make status # Check container status
make health # Run comprehensive diagnostics
make backup # Backup configurations
make clean # Clean up Docker resources
```

For detailed diagnostics:
```bash
# Internal health check (comprehensive diagnostics)
./scripts/health-check.sh
```

---

## 🔄 Version Management
Expand Down
1 change: 1 addition & 0 deletions docs/COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This document provides a comprehensive guide to all available commands in the La
| `make help` | Show all available commands with descriptions | `make help` |
| `make version` | Show current project version | `make version` |
| `make status` | Show container and environment status | `make status` |
| `make health` | Run comprehensive health diagnostics | `make health` |

### Container Management

Expand Down
55 changes: 29 additions & 26 deletions scripts/health-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,30 @@ health_check() {

# Check container status
log_info "Checking container status..."
if docker compose ps | grep -q "$CONTAINER_NAME"; then
if docker compose ps | grep -q "Up"; then
log_success "Container is running"

# Check container health
log_info "Checking container health..."
CONTAINER_STATUS=$(docker inspect "$CONTAINER_NAME" --format='{{.State.Status}}')
CONTAINER_HEALTH=$(docker inspect "$CONTAINER_NAME" --format='{{.State.Health.Status}}' 2>/dev/null || echo "No health check")

echo " Status: $CONTAINER_STATUS"
echo " Health: $CONTAINER_HEALTH"

# Check if we can execute commands in the container
if docker exec "$CONTAINER_NAME" echo "Container accessible" >/dev/null 2>&1; then
log_success "Container is accessible"
else
log_warning "Container is not accessible"
fi

CONTAINER_STATE=$(docker inspect "$CONTAINER_NAME" 2>/dev/null | grep '"Status"' | cut -d'"' -f4 || echo "missing")

if [ "$CONTAINER_STATE" = "missing" ]; then
log_warning "Container does not exist"
echo " Use 'make build' to create it"
elif [ "$CONTAINER_STATE" = "running" ]; then
log_success "Container is running"

# Check container health
log_info "Checking container health..."
CONTAINER_HEALTH=$(docker inspect "$CONTAINER_NAME" --format='{{.State.Health.Status}}' 2>/dev/null || echo "No health check")

echo " Status: $CONTAINER_STATE"
echo " Health: $CONTAINER_HEALTH"

# Check if we can execute commands in the container
if docker exec "$CONTAINER_NAME" echo "Container accessible" >/dev/null 2>&1; then
log_success "Container is accessible"
else
log_warning "Container exists but is not running"
echo " Use 'make start' to start it"
log_warning "Container is not accessible"
fi
else
log_warning "Container does not exist"
echo " Use 'make build' to create it"
log_warning "Container exists but is stopped ($CONTAINER_STATE)"
echo " Use 'make start' to start it"
fi

print_separator
Expand Down Expand Up @@ -152,12 +150,17 @@ health_check() {
# Final status
log_info "Health check completed"

if docker compose ps | grep -q "Up"; then
FINAL_CONTAINER_STATE=$(docker inspect "$CONTAINER_NAME" 2>/dev/null | grep '"Status"' | cut -d'"' -f4 || echo "missing")

if [ "$FINAL_CONTAINER_STATE" = "running" ]; then
log_success "Environment is ready to use!"
echo " Use 'make enter' or 'docker exec -it $CONTAINER_NAME zsh' to access"
echo " Use 'make enter' to access the container"
elif [ "$FINAL_CONTAINER_STATE" = "missing" ]; then
log_info "Environment is not built"
echo " Use 'make build' to create the container"
else
log_info "Environment is not running"
echo " Use 'make start' to start or 'make build' to rebuild"
echo " Use 'make start' to start the existing container"
fi
}

Expand Down