feat: add registry config, image upload/download, and OCI format support
Backend: - Add registry_address configuration API (GET/POST) - Add tar image upload with OCI and Docker format support - Add image download with streaming optimization - Fix blob download using c.Send (Fiber v3 SendStream bug) - Add registry_address prefix stripping for all OCI v2 endpoints - Add AGENTS.md for project documentation Frontend: - Add settings store with Snackbar notifications - Add image upload dialog with progress bar - Add download state tracking with multi-stage feedback - Replace alert() with MUI Snackbar messages - Display image names without registry_address prefix 🤖 Generated with [Qoder](https://qoder.com)
This commit is contained in:
111
dev.sh
111
dev.sh
@@ -1,78 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run backend (Go) and frontend (Vite) together; stop both on Ctrl+C
|
||||
set -euo pipefail
|
||||
|
||||
# Always run from repo root
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Get the directory where the script is located
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
BACKEND_ADDR=${BACKEND_ADDR:-0.0.0.0:9119}
|
||||
DATA_DIR=${DATA_DIR:-./x-storage}
|
||||
|
||||
# Store PIDs for cleanup
|
||||
BACKEND_PID=""
|
||||
FRONTEND_PID=""
|
||||
|
||||
# Function to cleanup background processes
|
||||
cleanup() {
|
||||
echo ""
|
||||
echo "[dev] Shutting down..."
|
||||
|
||||
# Kill backend if running
|
||||
if [ -n "$BACKEND_PID" ] && kill -0 "$BACKEND_PID" 2>/dev/null; then
|
||||
echo "[dev] Stopping backend (PID: $BACKEND_PID)..."
|
||||
kill "$BACKEND_PID" 2>/dev/null || true
|
||||
wait "$BACKEND_PID" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Kill frontend if running
|
||||
if [ -n "$FRONTEND_PID" ] && kill -0 "$FRONTEND_PID" 2>/dev/null; then
|
||||
echo "[dev] Stopping frontend (PID: $FRONTEND_PID)..."
|
||||
kill "$FRONTEND_PID" 2>/dev/null || true
|
||||
wait "$FRONTEND_PID" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Kill any remaining background jobs
|
||||
if command -v xargs >/dev/null 2>&1; then
|
||||
jobs -p | xargs kill 2>/dev/null || true
|
||||
else
|
||||
# Fallback for systems without xargs -r
|
||||
for job in $(jobs -p); do
|
||||
kill "$job" 2>/dev/null || true
|
||||
done
|
||||
fi
|
||||
|
||||
# Wait a bit for graceful shutdown
|
||||
sleep 1
|
||||
|
||||
# Force kill if still running
|
||||
if [ -n "$BACKEND_PID" ] && kill -0 "$BACKEND_PID" 2>/dev/null; then
|
||||
kill -9 "$BACKEND_PID" 2>/dev/null || true
|
||||
fi
|
||||
if [ -n "$FRONTEND_PID" ] && kill -0 "$FRONTEND_PID" 2>/dev/null; then
|
||||
kill -9 "$FRONTEND_PID" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo "[dev] Shutdown complete"
|
||||
exit 0
|
||||
echo -e "\n${YELLOW}Shutting down services...${NC}"
|
||||
if [ ! -z "$BACKEND_PID" ]; then
|
||||
kill $BACKEND_PID 2>/dev/null || true
|
||||
wait $BACKEND_PID 2>/dev/null || true
|
||||
fi
|
||||
if [ ! -z "$FRONTEND_PID" ]; then
|
||||
kill $FRONTEND_PID 2>/dev/null || true
|
||||
wait $FRONTEND_PID 2>/dev/null || true
|
||||
fi
|
||||
echo -e "${GREEN}All services stopped.${NC}"
|
||||
exit 0
|
||||
}
|
||||
|
||||
trap cleanup INT TERM EXIT
|
||||
# Trap Ctrl+C and cleanup
|
||||
trap cleanup SIGINT SIGTERM
|
||||
|
||||
# Start backend
|
||||
echo "[dev] Starting backend on $BACKEND_ADDR (data-dir=$DATA_DIR)"
|
||||
go run . --debug --address "$BACKEND_ADDR" --data-dir "$DATA_DIR" &
|
||||
# Check if pnpm is available, otherwise use npm
|
||||
if command -v pnpm &> /dev/null; then
|
||||
PACKAGE_MANAGER="pnpm"
|
||||
elif command -v npm &> /dev/null; then
|
||||
PACKAGE_MANAGER="npm"
|
||||
else
|
||||
echo -e "${RED}Error: Neither pnpm nor npm is installed.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if Go is installed
|
||||
if ! command -v go &> /dev/null; then
|
||||
echo -e "${RED}Error: Go is not installed.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}Starting backend (Go)...${NC}"
|
||||
go run main.go &
|
||||
BACKEND_PID=$!
|
||||
|
||||
# Wait a moment for backend to start
|
||||
sleep 2
|
||||
|
||||
# Start frontend
|
||||
echo "[dev] Starting frontend dev server (Vite)"
|
||||
(cd frontend && pnpm run dev) &
|
||||
echo -e "${GREEN}Starting frontend (Vite)...${NC}"
|
||||
cd frontend
|
||||
$PACKAGE_MANAGER run dev &
|
||||
FRONTEND_PID=$!
|
||||
cd ..
|
||||
|
||||
echo "[dev] Backend PID: $BACKEND_PID, Frontend PID: $FRONTEND_PID"
|
||||
echo "[dev] Press Ctrl+C to stop both..."
|
||||
echo -e "${GREEN}Both services are running!${NC}"
|
||||
echo -e "${YELLOW}Backend PID: $BACKEND_PID${NC}"
|
||||
echo -e "${YELLOW}Frontend PID: $FRONTEND_PID${NC}"
|
||||
echo -e "${YELLOW}Press Ctrl+C to stop both services${NC}"
|
||||
|
||||
# Wait for both processes to exit
|
||||
wait $BACKEND_PID $FRONTEND_PID
|
||||
# Wait for both processes
|
||||
wait $BACKEND_PID $FRONTEND_PID
|
||||
Reference in New Issue
Block a user