Init
This commit is contained in:
163
Justfile
Normal file
163
Justfile
Normal file
@@ -0,0 +1,163 @@
|
||||
# JupyterHub Notebook Viewer - Development Commands
|
||||
|
||||
# Default recipe
|
||||
default:
|
||||
@just --list
|
||||
|
||||
# Set up development environment
|
||||
setup:
|
||||
@echo "Setting up development environment..."
|
||||
mkdir -p shared notebooks templates
|
||||
[ ! -f .env ] && cp .env.example .env || true
|
||||
@echo "✓ Development environment ready"
|
||||
|
||||
# Start development server
|
||||
dev:
|
||||
@echo "Starting development server..."
|
||||
python app.py
|
||||
|
||||
# Start development server with auto-reload (using nix shell)
|
||||
dev-nix:
|
||||
nix develop --command dev-server
|
||||
|
||||
# Run tests
|
||||
test:
|
||||
@echo "Running tests..."
|
||||
python -m pytest tests/ -v || python -c "import app; print('Basic import test passed')"
|
||||
|
||||
# Run tests in nix environment
|
||||
test-nix:
|
||||
nix develop --command run-tests
|
||||
|
||||
# Build Docker image
|
||||
docker-build:
|
||||
docker build -t jupyterhub-notebook-viewer .
|
||||
|
||||
# Start with Docker Compose
|
||||
docker-up:
|
||||
docker-compose up
|
||||
|
||||
# Start with Docker Compose in background
|
||||
docker-up-daemon:
|
||||
docker-compose up -d
|
||||
|
||||
# Start with Docker Compose and rebuild
|
||||
docker-rebuild:
|
||||
docker-compose up --build
|
||||
|
||||
# Start with nginx proxy
|
||||
docker-proxy:
|
||||
docker-compose --profile with-proxy up
|
||||
|
||||
# Stop Docker services
|
||||
docker-down:
|
||||
docker-compose down
|
||||
|
||||
# View Docker logs
|
||||
docker-logs:
|
||||
docker-compose logs -f
|
||||
|
||||
# Clean Docker resources
|
||||
docker-clean:
|
||||
docker-compose down -v
|
||||
docker system prune -f
|
||||
|
||||
# Install Python dependencies
|
||||
install:
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Format code
|
||||
format:
|
||||
black app.py
|
||||
isort app.py
|
||||
|
||||
# Lint code
|
||||
lint:
|
||||
flake8 app.py
|
||||
pylint app.py
|
||||
|
||||
# Generate requirements.txt
|
||||
freeze:
|
||||
pip freeze > requirements.txt
|
||||
|
||||
# Create sample notebook
|
||||
sample-notebook:
|
||||
@mkdir -p shared
|
||||
@cat > shared/sample.ipynb << 'EOF'
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Sample Notebook\n\nThis is a sample Jupyter notebook."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print('Hello World!')\nimport numpy as np\nprint(f'NumPy version: {np.__version__}')"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
EOF
|
||||
@echo "✓ Sample notebook created in shared/sample.ipynb"
|
||||
|
||||
# Check environment configuration
|
||||
check-env:
|
||||
@echo "Environment Configuration:"
|
||||
@echo "========================="
|
||||
@grep -E '^[A-Z_]' .env 2>/dev/null || echo "No .env file found"
|
||||
@echo ""
|
||||
@echo "Current Python: $(which python)"
|
||||
@echo "Flask available: $(python -c 'import flask; print(flask.__version__)' 2>/dev/null || echo 'Not installed')"
|
||||
@echo "Shared directory: ${JUPYTERHUB_SHARED_DIR:-./shared}"
|
||||
|
||||
# Show application logs
|
||||
logs:
|
||||
tail -f app.log 2>/dev/null || echo "No log file found"
|
||||
|
||||
# Clean temporary files
|
||||
clean:
|
||||
rm -rf __pycache__/
|
||||
rm -rf .pytest_cache/
|
||||
rm -rf *.pyc
|
||||
rm -rf .coverage
|
||||
rm -rf htmlcov/
|
||||
rm -rf dist/
|
||||
rm -rf build/
|
||||
rm -rf *.egg-info/
|
||||
|
||||
# Security scan
|
||||
security:
|
||||
safety check -r requirements.txt || echo "Safety not installed, skipping security scan"
|
||||
bandit -r . -f json || echo "Bandit not installed, skipping security scan"
|
||||
|
||||
# Performance test
|
||||
perf:
|
||||
@echo "Running performance test..."
|
||||
ab -n 100 -c 10 http://localhost:5000/ || echo "Apache Bench not available"
|
||||
|
||||
# Health check
|
||||
health:
|
||||
curl -f http://localhost:5000/ || echo "Application not responding"
|
||||
|
||||
# Generate documentation
|
||||
docs:
|
||||
@echo "Generating documentation..."
|
||||
mkdir -p docs
|
||||
@echo "# JupyterHub Notebook Viewer\n\nGenerated documentation\n" > docs/README.md
|
||||
@echo "✓ Documentation generated in docs/"
|
Reference in New Issue
Block a user