mirror of
https://github.com/ryankazokas/turbovault-app.git
synced 2026-04-16 22:12:53 +00:00
Moving to github
This commit is contained in:
218
scripts/deploy-k8s.sh
Executable file
218
scripts/deploy-k8s.sh
Executable file
@@ -0,0 +1,218 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TurboVault Kubernetes Deployment Script
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 TurboVault Kubernetes Deployment"
|
||||
echo "===================================="
|
||||
echo ""
|
||||
|
||||
# Configuration
|
||||
NAMESPACE="turbovault"
|
||||
IMAGE_NAME="turbovault"
|
||||
REGISTRY="" # e.g., ghcr.io/username or docker.io/username
|
||||
|
||||
# Color codes
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Check prerequisites
|
||||
echo "📋 Checking prerequisites..."
|
||||
|
||||
if ! command -v kubectl &> /dev/null; then
|
||||
echo -e "${RED}❌ kubectl not found. Please install kubectl.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo -e "${RED}❌ docker not found. Please install Docker.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✅ Prerequisites check passed${NC}"
|
||||
echo ""
|
||||
|
||||
# Get version/tag
|
||||
read -p "Enter version tag (default: latest): " VERSION
|
||||
VERSION=${VERSION:-latest}
|
||||
|
||||
# Get registry
|
||||
echo ""
|
||||
echo "Enter your container registry details:"
|
||||
echo "Examples:"
|
||||
echo " - ghcr.io/username"
|
||||
echo " - docker.io/username"
|
||||
echo " - registry.example.com/myapp"
|
||||
read -p "Registry path: " REGISTRY_INPUT
|
||||
if [ -z "$REGISTRY_INPUT" ]; then
|
||||
echo -e "${RED}❌ Registry path is required${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMAGE_TAG="${REGISTRY_INPUT}/${IMAGE_NAME}:${VERSION}"
|
||||
|
||||
echo ""
|
||||
echo "📝 Configuration:"
|
||||
echo " Namespace: $NAMESPACE"
|
||||
echo " Image: $IMAGE_TAG"
|
||||
echo ""
|
||||
|
||||
# Build and push image
|
||||
read -p "Build and push Docker image? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo ""
|
||||
echo "🏗️ Building Docker image..."
|
||||
docker build -t "$IMAGE_TAG" .
|
||||
|
||||
echo ""
|
||||
echo "📤 Pushing to registry..."
|
||||
docker push "$IMAGE_TAG"
|
||||
|
||||
echo -e "${GREEN}✅ Image built and pushed${NC}"
|
||||
fi
|
||||
|
||||
# Update deployment with new image
|
||||
echo ""
|
||||
echo "📝 Updating deployment.yaml with new image..."
|
||||
sed -i.bak "s|image:.*turbovault.*|image: $IMAGE_TAG|g" k8s/deployment.yaml
|
||||
sed -i.bak "s|image:.*turbovault.*|image: $IMAGE_TAG|g" k8s/migrate-job.yaml
|
||||
rm k8s/*.bak
|
||||
echo -e "${GREEN}✅ Deployment files updated${NC}"
|
||||
|
||||
# Check if secrets exist
|
||||
if [ ! -f k8s/secrets.yaml ]; then
|
||||
echo ""
|
||||
echo -e "${YELLOW}⚠️ secrets.yaml not found!${NC}"
|
||||
echo " Please create k8s/secrets.yaml from k8s/secrets.yaml.example"
|
||||
echo " and add your actual secrets."
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if using private registry
|
||||
echo ""
|
||||
read -p "Is this a private registry that requires authentication? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "🔐 Checking for registry secret..."
|
||||
if ! kubectl get secret registry-secret -n $NAMESPACE 2>/dev/null; then
|
||||
echo -e "${YELLOW}⚠️ Registry secret not found!${NC}"
|
||||
echo ""
|
||||
echo "You need to create a secret for pulling images from your private registry."
|
||||
echo ""
|
||||
read -p "Create the secret now? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo ""
|
||||
read -p "Registry server (e.g., registry.example.com): " REGISTRY_SERVER
|
||||
read -p "Username: " REGISTRY_USER
|
||||
read -sp "Password/Token: " REGISTRY_PASS
|
||||
echo ""
|
||||
read -p "Email: " REGISTRY_EMAIL
|
||||
|
||||
kubectl create secret docker-registry registry-secret \
|
||||
--docker-server="$REGISTRY_SERVER" \
|
||||
--docker-username="$REGISTRY_USER" \
|
||||
--docker-password="$REGISTRY_PASS" \
|
||||
--docker-email="$REGISTRY_EMAIL" \
|
||||
--namespace=$NAMESPACE
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${GREEN}✅ Registry secret created${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Failed to create secret${NC}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Please create the secret manually before deploying."
|
||||
echo ""
|
||||
echo "kubectl create secret docker-registry registry-secret \\"
|
||||
echo " --docker-server=your-registry.com \\"
|
||||
echo " --docker-username=your-username \\"
|
||||
echo " --docker-password=your-token \\"
|
||||
echo " --docker-email=your-email \\"
|
||||
echo " --namespace=$NAMESPACE"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "${GREEN}✅ Registry secret exists${NC}"
|
||||
fi
|
||||
else
|
||||
echo "ℹ️ Using public registry (no authentication needed)"
|
||||
fi
|
||||
|
||||
# Deploy
|
||||
echo ""
|
||||
read -p "Deploy to Kubernetes? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Deployment cancelled."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🚀 Deploying to Kubernetes..."
|
||||
echo ""
|
||||
|
||||
# Create namespace
|
||||
echo "Creating namespace..."
|
||||
kubectl apply -f k8s/namespace.yaml
|
||||
|
||||
# Apply ConfigMap
|
||||
echo "Applying ConfigMap..."
|
||||
kubectl apply -f k8s/configmap.yaml
|
||||
|
||||
# Apply Secrets
|
||||
echo "Applying Secrets..."
|
||||
kubectl apply -f k8s/secrets.yaml
|
||||
|
||||
# Run migrations
|
||||
echo ""
|
||||
echo "🗄️ Running database migrations..."
|
||||
kubectl delete job turbovault-migrate -n $NAMESPACE 2>/dev/null || true
|
||||
kubectl apply -f k8s/migrate-job.yaml
|
||||
|
||||
echo "Waiting for migrations to complete..."
|
||||
if kubectl wait --for=condition=complete --timeout=300s job/turbovault-migrate -n $NAMESPACE 2>/dev/null; then
|
||||
echo -e "${GREEN}✅ Migrations completed${NC}"
|
||||
else
|
||||
echo -e "${RED}❌ Migration failed or timed out${NC}"
|
||||
echo "Check logs with: kubectl logs job/turbovault-migrate -n $NAMESPACE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Deploy application
|
||||
echo ""
|
||||
echo "📦 Deploying application..."
|
||||
kubectl apply -f k8s/deployment.yaml
|
||||
|
||||
# Create service
|
||||
echo "Creating service..."
|
||||
kubectl apply -f k8s/service.yaml
|
||||
|
||||
# Create ingress
|
||||
echo "Creating ingress..."
|
||||
kubectl apply -f k8s/ingress.yaml
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}✅ Deployment complete!${NC}"
|
||||
echo ""
|
||||
echo "📊 Checking status..."
|
||||
kubectl get pods -n $NAMESPACE
|
||||
echo ""
|
||||
kubectl get svc -n $NAMESPACE
|
||||
echo ""
|
||||
kubectl get ingress -n $NAMESPACE
|
||||
|
||||
echo ""
|
||||
echo "🔍 Useful commands:"
|
||||
echo " View logs: kubectl logs -f -l app=turbovault -n $NAMESPACE"
|
||||
echo " Check pods: kubectl get pods -n $NAMESPACE"
|
||||
echo " Port forward: kubectl port-forward svc/turbovault-service 3000:80 -n $NAMESPACE"
|
||||
echo " Shell access: kubectl exec -it deployment/turbovault -n $NAMESPACE -- /bin/bash"
|
||||
echo ""
|
||||
echo "🎉 Done!"
|
||||
125
scripts/setup-github.sh
Executable file
125
scripts/setup-github.sh
Executable file
@@ -0,0 +1,125 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TurboVault GitHub Setup Script
|
||||
# This script helps you push your code to GitHub
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 TurboVault GitHub Setup"
|
||||
echo "=========================="
|
||||
echo ""
|
||||
|
||||
# Check if we're in a git repo
|
||||
if [ ! -d .git ]; then
|
||||
echo "❌ Error: Not a git repository"
|
||||
echo " Run: git init"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get GitHub username
|
||||
read -p "Enter your GitHub username: " GITHUB_USER
|
||||
|
||||
# Get repository name (default: turbovault)
|
||||
read -p "Enter repository name [turbovault]: " REPO_NAME
|
||||
REPO_NAME=${REPO_NAME:-turbovault}
|
||||
|
||||
echo ""
|
||||
echo "📝 Configuration:"
|
||||
echo " GitHub User: $GITHUB_USER"
|
||||
echo " Repository: $REPO_NAME"
|
||||
echo " URL: https://github.com/$GITHUB_USER/$REPO_NAME"
|
||||
echo ""
|
||||
|
||||
read -p "Is this correct? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Aborted."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🔧 Setting up Git remotes..."
|
||||
|
||||
# Check if origin already exists
|
||||
if git remote | grep -q "^origin$"; then
|
||||
echo " ⚠️ Remote 'origin' already exists"
|
||||
read -p " Remove and re-add? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
git remote remove origin
|
||||
else
|
||||
echo "Aborted."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Add GitHub as origin
|
||||
git remote add origin "https://github.com/$GITHUB_USER/$REPO_NAME.git"
|
||||
echo " ✅ Added GitHub remote 'origin'"
|
||||
|
||||
# Optional: Add Gitea as a second remote
|
||||
read -p "Do you want to add Gitea as a second remote? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
read -p "Enter Gitea remote URL (e.g., https://gitea.example.com/user/repo.git): " GITEA_URL
|
||||
if [ ! -z "$GITEA_URL" ]; then
|
||||
git remote add gitea "$GITEA_URL"
|
||||
echo " ✅ Added Gitea remote 'gitea'"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "📦 Committing files..."
|
||||
|
||||
# Add all files
|
||||
git add .
|
||||
|
||||
# Commit
|
||||
git commit -m "Initial commit - TurboVault v1.0
|
||||
|
||||
Features:
|
||||
- Full CRUD for video game collection
|
||||
- IGDB integration for metadata
|
||||
- Collections and genres
|
||||
- Physical/Digital tracking
|
||||
- CSV import/export
|
||||
- RESTful API
|
||||
- 5 beautiful themes
|
||||
- Public profiles"
|
||||
|
||||
echo " ✅ Created initial commit"
|
||||
|
||||
echo ""
|
||||
echo "🚀 Pushing to GitHub..."
|
||||
|
||||
# Set main as default branch
|
||||
git branch -M main
|
||||
|
||||
# Push to GitHub
|
||||
git push -u origin main
|
||||
|
||||
echo ""
|
||||
echo "✅ Success! Your code is now on GitHub!"
|
||||
echo ""
|
||||
echo "🔗 View your repository:"
|
||||
echo " https://github.com/$GITHUB_USER/$REPO_NAME"
|
||||
echo ""
|
||||
echo "📚 Next steps:"
|
||||
echo " 1. Visit your repository and add a description"
|
||||
echo " 2. Add topics/tags (rails, ruby, gaming, collection-tracker)"
|
||||
echo " 3. Enable GitHub Pages (optional)"
|
||||
echo " 4. Set up GitHub Actions for CI/CD (optional)"
|
||||
echo ""
|
||||
|
||||
# Optional: Push to Gitea too
|
||||
if git remote | grep -q "^gitea$"; then
|
||||
read -p "Push to Gitea as well? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
git push -u gitea main
|
||||
echo " ✅ Pushed to Gitea"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "🎉 All done!"
|
||||
Reference in New Issue
Block a user