Add multi-image compositions, docker setup, tests, and docs
- Add CompositionImage model with multi-image upload and main image flag - Add composition endpoints: add-images, set-main-image, delete image, by-created-at filter - Make contact-us by_category public - Add 24 API tests covering all endpoints - Add Dockerfile, docker-compose, entrypoint and docker docs - Add Persian API docs and update README and Postman collection Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
122
docker-commands.sh
Normal file
122
docker-commands.sh
Normal file
@@ -0,0 +1,122 @@
|
||||
#!/bin/bash
|
||||
# Helper script for common Docker operations
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Function to print colored output
|
||||
print_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Check if .env file exists
|
||||
if [ ! -f .env ]; then
|
||||
print_warn ".env file not found. Creating from template..."
|
||||
cat > .env << EOF
|
||||
SECRET_KEY=$(python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())")
|
||||
DEBUG=False
|
||||
ALLOWED_HOSTS=localhost,127.0.0.1,185.208.172.158
|
||||
POSTGRES_DB=Zoneco_ORG
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=postgres
|
||||
POSTGRES_HOST=db
|
||||
POSTGRES_PORT=5432
|
||||
DJANGO_PORT=8000
|
||||
CORS_ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3000,http://127.0.0.1:5173,http://127.0.0.1:3000,http://185.208.172.158:9123,http://185.208.172.158
|
||||
EOF
|
||||
print_info ".env file created with generated SECRET_KEY"
|
||||
fi
|
||||
|
||||
# Parse command
|
||||
case "$1" in
|
||||
up)
|
||||
print_info "Starting Docker containers..."
|
||||
docker-compose up -d
|
||||
print_info "Containers started. Use 'docker-compose logs -f' to view logs."
|
||||
;;
|
||||
down)
|
||||
print_info "Stopping Docker containers..."
|
||||
docker-compose down
|
||||
;;
|
||||
restart)
|
||||
print_info "Restarting Docker containers..."
|
||||
docker-compose restart
|
||||
;;
|
||||
logs)
|
||||
print_info "Showing logs (Ctrl+C to exit)..."
|
||||
docker-compose logs -f
|
||||
;;
|
||||
shell)
|
||||
print_info "Opening Django shell..."
|
||||
docker-compose exec web python manage.py shell
|
||||
;;
|
||||
migrate)
|
||||
print_info "Running migrations..."
|
||||
docker-compose exec web python manage.py migrate
|
||||
;;
|
||||
makemigrations)
|
||||
print_info "Creating migrations..."
|
||||
docker-compose exec web python manage.py makemigrations
|
||||
;;
|
||||
createsuperuser)
|
||||
print_info "Creating superuser..."
|
||||
docker-compose exec web python manage.py createsuperuser
|
||||
;;
|
||||
collectstatic)
|
||||
print_info "Collecting static files..."
|
||||
docker-compose exec web python manage.py collectstatic --noinput
|
||||
;;
|
||||
rebuild)
|
||||
print_info "Rebuilding containers..."
|
||||
docker-compose build --no-cache
|
||||
print_info "Containers rebuilt. Use './docker-commands.sh up' to start."
|
||||
;;
|
||||
clean)
|
||||
print_warn "This will remove all containers, volumes, and images. Are you sure? (y/N)"
|
||||
read -r response
|
||||
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
|
||||
print_info "Cleaning up..."
|
||||
docker-compose down -v
|
||||
docker system prune -f
|
||||
print_info "Cleanup complete."
|
||||
else
|
||||
print_info "Cleanup cancelled."
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
print_info "Container status:"
|
||||
docker-compose ps
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {up|down|restart|logs|shell|migrate|makemigrations|createsuperuser|collectstatic|rebuild|clean|status}"
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " up - Start containers in detached mode"
|
||||
echo " down - Stop containers"
|
||||
echo " restart - Restart containers"
|
||||
echo " logs - Show logs (follow mode)"
|
||||
echo " shell - Open Django shell"
|
||||
echo " migrate - Run database migrations"
|
||||
echo " makemigrations - Create new migrations"
|
||||
echo " createsuperuser - Create Django superuser"
|
||||
echo " collectstatic - Collect static files"
|
||||
echo " rebuild - Rebuild containers (no cache)"
|
||||
echo " clean - Remove all containers and volumes"
|
||||
echo " status - Show container status"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user