Commit 8ce433a5 authored by AGLANPC\aglan's avatar AGLANPC\aglan

fgjfgh jfyhg

parent d2be0f62
...@@ -4,42 +4,53 @@ FROM php:8.2-apache ...@@ -4,42 +4,53 @@ FROM php:8.2-apache
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
libpng-dev libjpeg-dev libfreetype6-dev \ libpng-dev libjpeg-dev libfreetype6-dev \
libzip-dev libonig-dev libxml2-dev \ libzip-dev libonig-dev libxml2-dev \
zip unzip curl git \ zip unzip curl \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install pdo pdo_mysql mbstring zip gd xml opcache \ && docker-php-ext-install pdo pdo_mysql mbstring zip gd xml opcache \
&& apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get clean && rm -rf /var/lib/apt/lists/*
# ── Apache: point DocumentRoot at public/ and enable mod_rewrite ───────────── # ── Apache config ────────────────────────────────────────────────────────────
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN sed -i 's|DocumentRoot /var/www/html|DocumentRoot /var/www/html/public|g' \ RUN sed -i 's|DocumentRoot /var/www/html|DocumentRoot /var/www/html/public|g' \
/etc/apache2/sites-available/000-default.conf \ /etc/apache2/sites-available/000-default.conf \
&& sed -i 's|<Directory /var/www/html>|<Directory /var/www/html/public>|g' \ && sed -i '/<Directory \/var\/www\/>/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' \
/etc/apache2/apache2.conf \ /etc/apache2/apache2.conf \
&& echo '<Directory /var/www/html/public>\n AllowOverride All\n Require all granted\n</Directory>' \ && echo '<Directory /var/www/html/public>\n AllowOverride All\n Require all granted\n</Directory>' \
>> /etc/apache2/apache2.conf \ >> /etc/apache2/apache2.conf \
&& a2enmod rewrite && a2enmod rewrite
# ── PHP production settings ─────────────────────────────────────────────────── # ── PHP settings (errors ON for now so we can debug) ─────────────────────────
RUN echo "display_errors = Off\n\ RUN echo "display_errors = On\n\
error_reporting = E_ALL\n\ error_reporting = E_ALL\n\
log_errors = On\n\ log_errors = On\n\
error_log = /var/log/php_errors.log\n\ error_log = /proc/self/fd/2\n\
upload_max_filesize = 20M\n\ upload_max_filesize = 20M\n\
post_max_size = 22M\n\ post_max_size = 22M\n\
memory_limit = 256M\n\ memory_limit = 256M\n\
max_execution_time = 60\n\ max_execution_time = 60\n\
opcache.enable = 1\n\ opcache.enable = 1\n\
opcache.memory_consumption = 128\n\ opcache.memory_consumption = 128\n\
opcache.validate_timestamps = 0" > /usr/local/etc/php/conf.d/production.ini opcache.validate_timestamps = 1" > /usr/local/etc/php/conf.d/app.ini
# ── Copy application files ────────────────────────────────────────────────────
WORKDIR /var/www/html WORKDIR /var/www/html
COPY . . COPY . .
# ── Create required directories & set permissions ──────────────────────────── # ── Make sure public/.htaccess exists for routing ────────────────────────────
RUN if [ ! -f public/.htaccess ]; then \
echo '<IfModule mod_rewrite.c>\n\
RewriteEngine On\n\
RewriteCond %{REQUEST_FILENAME} !-f\n\
RewriteCond %{REQUEST_FILENAME} !-d\n\
RewriteRule ^(.*)$ index.php [QSA,L]\n\
</IfModule>' > public/.htaccess; \
fi
# ── Directories & permissions ────────────────────────────────────────────────
RUN mkdir -p storage/logs storage/uploads \ RUN mkdir -p storage/logs storage/uploads \
&& chown -R www-data:www-data /var/www/html \ && chown -R www-data:www-data /var/www/html \
&& chmod -R 775 storage && chmod -R 775 storage
EXPOSE 80 EXPOSE 80
CMD ["apache2-foreground"]
\ No newline at end of file
This diff is collapsed.
$outputFile = "codebase.md"
$projectRoot = Get-Location
$includeExtensions = @(
"*.php", "*.html", "*.htm", "*.css", "*.js", "*.json",
"*.sql", "*.env", "*.env.example", "*.ini", "*.conf",
"*.xml", "*.yaml", "*.yml", "*.txt", "*.md",
"*.sh", "*.bash", "*.py", "*.twig",
"*.htaccess", "*.config", "*.lock",
"Dockerfile", "docker-compose*", "captain-definition"
)
$excludeDirs = @(
"vendor", "node_modules", ".git", ".idea", ".vscode",
"storage", "cache", ".cache", "tmp", "temp",
"dist", "build", "public/build", ".docker", "logs"
)
$excludeFiles = @(
"codebase.md", "codebase.txt", "combine-codebase.ps1",
"collectcodebase.ps1", "composer.lock", "package-lock.json", "yarn.lock"
)
$excludePattern = ($excludeDirs | ForEach-Object { [regex]::Escape($_) }) -join "|"
$excludeRegex = "(\\|/)($excludePattern)(\\|/|$)"
$allFiles = @()
foreach ($ext in $includeExtensions) {
$found = Get-ChildItem -Path $projectRoot -Filter $ext -Recurse -File -ErrorAction SilentlyContinue
$allFiles += $found
}
$specialFiles = @("Dockerfile", "Makefile", "Procfile", "captain-definition", ".htaccess", ".env.example")
foreach ($name in $specialFiles) {
$found = Get-ChildItem -Path $projectRoot -Filter $name -Recurse -File -ErrorAction SilentlyContinue
$allFiles += $found
}
$allFiles = $allFiles | Sort-Object FullName -Unique
$filtered = $allFiles | Where-Object {
$relativePath = $_.FullName.Substring($projectRoot.Path.Length)
$fileName = $_.Name
($relativePath -notmatch $excludeRegex) -and ($fileName -notin $excludeFiles)
}
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$header = @"
# Full Codebase Export
Generated: $timestamp
Project: $projectRoot
Files: $($filtered.Count)
---
"@
Set-Content -Path $outputFile -Value $header -Encoding UTF8
$fence = "``````"
$fileCount = 0
foreach ($file in $filtered) {
$relativePath = $file.FullName.Substring($projectRoot.Path.Length + 1)
$extension = $file.Extension.TrimStart(".")
if (-not $extension) { $extension = "text" }
$fileCount++
$separator = "`n## File: $relativePath`n"
Add-Content -Path $outputFile -Value $separator -Encoding UTF8
$openFence = "${fence}${extension}"
Add-Content -Path $outputFile -Value $openFence -Encoding UTF8
try {
$content = Get-Content -Path $file.FullName -Raw -ErrorAction Stop
Add-Content -Path $outputFile -Value $content -Encoding UTF8
}
catch {
Add-Content -Path $outputFile -Value "[ERROR: Could not read file]" -Encoding UTF8
}
Add-Content -Path $outputFile -Value $fence -Encoding UTF8
Write-Host "[$fileCount] $relativePath" -ForegroundColor Green
}
$fileSize = [math]::Round((Get-Item $outputFile).Length / 1KB, 1)
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host " Done! $fileCount files combined" -ForegroundColor Cyan
Write-Host " Output: $outputFile ($fileSize KB)" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
\ No newline at end of file
#!/usr/bin/env bash #!/usr/bin/env bash
# ============================================================================= # =============================================================================
# Club Management System — Full CapRover Deploy Script # Club Management System — Full CapRover Deploy Script
# Run this on a fresh Ubuntu 22.04 SSH session on your CapRover server, # Usage: chmod +x deploy.sh && ./deploy.sh
# OR from any machine that has SSH + internet access.
#
# Usage:
# chmod +x deploy.sh
# ./deploy.sh
# ============================================================================= # =============================================================================
set -e set -e
# ─── CONFIGURATION ────────────────────────────────────────────────────────── # ─── CONFIGURATION ───────────────────────────────────────────────────────────
# Edit these before running CAPROVER_URL="http://captain.caprover.al-arcade.com"
CAPROVER_URL="http://captain.caprover.al-arcade.com" # Your CapRover dashboard URL CAPROVER_PASSWORD="Alarcade123#"
CAPROVER_PASSWORD="Alarcade123#" # CapRover admin password APP_NAME="club-management-club"
APP_NAME="club-management-club" # The CapRover app name to create/update
GITLAB_REPO="http://gitlab.caprover.al-arcade.com/root/finalclubmanagementphp.git" GITLAB_REPO="http://gitlab.caprover.al-arcade.com/root/finalclubmanagementphp.git"
GITLAB_USER="root" GITLAB_USER="root"
GITLAB_TOKEN="vHATWUzqfUC1nkXkGkai" # GitLab → Settings → Access Tokens GITLAB_TOKEN="vHATWUzqfUC1nkXkGkai"
# DB config — your existing database server # Existing DB server
DB_HOST="srv-captain--mysql-db" # e.g. 192.168.1.10 or db.al-arcade.com DB_HOST="srv-captain--mysql-db"
DB_PORT="3306" DB_PORT="3306"
DB_NAME="club_management" DB_NAME="club_management"
DB_USER="root" DB_USER="root"
DB_PASS="Alarcade123#" DB_PASS="Alarcade123#"
APP_URL="https://${APP_NAME}.caprover.al-arcade.com" # or your custom domain APP_URL="https://${APP_NAME}.caprover.al-arcade.com"
# ─── COLORS ────────────────────────────────────────────────────────────────── # ─── COLORS ──────────────────────────────────────────────────────────────────
GREEN='\033[0;32m'; YELLOW='\033[1;33m'; RED='\033[0;31m'; NC='\033[0m' GREEN='\033[0;32m'; YELLOW='\033[1;33m'; RED='\033[0;31m'; NC='\033[0m'
...@@ -38,98 +32,90 @@ info "Checking prerequisites..." ...@@ -38,98 +32,90 @@ info "Checking prerequisites..."
if ! command -v node &>/dev/null; then if ! command -v node &>/dev/null; then
info "Installing Node.js 20..." info "Installing Node.js 20..."
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
sudo apt-get install -y nodejs apt-get install -y nodejs
fi fi
node -v node -v
if ! command -v caprover &>/dev/null; then if ! command -v caprover &>/dev/null; then
info "Installing CapRover CLI..." info "Installing CapRover CLI..."
sudo npm install -g caprover npm install -g caprover
fi fi
caprover --version caprover --version
if ! command -v git &>/dev/null; then command -v git &>/dev/null || { apt-get update && apt-get install -y git; }
sudo apt-get update && sudo apt-get install -y git command -v curl &>/dev/null || { apt-get update && apt-get install -y curl; }
fi
# ─── 2. CLONE OR PULL THE REPO ─────────────────────────────────────────────── # ─── 2. CLONE REPO ───────────────────────────────────────────────────────────
DEPLOY_DIR="/tmp/club_deploy_$(date +%s)" DEPLOY_DIR="/tmp/club_deploy_$(date +%s)"
info "Cloning repository to ${DEPLOY_DIR}..." info "Cloning repository to ${DEPLOY_DIR}..."
git clone "http://${GITLAB_USER}:${GITLAB_TOKEN}@$(echo $GITLAB_REPO | sed 's|http://||')" "$DEPLOY_DIR" git clone "http://${GITLAB_USER}:${GITLAB_TOKEN}@$(echo $GITLAB_REPO | sed 's|http://||')" "$DEPLOY_DIR"
cd "$DEPLOY_DIR" cd "$DEPLOY_DIR"
# ─── 3. SAFETY CLEANUP ─────────────────────────────────────────────────────── # ─── 3. SAFETY CLEANUP ───────────────────────────────────────────────────────
info "Removing sensitive dev files..." info "Removing sensitive/dead files..."
rm -f code.sql rm -f code.sql
rm -f core/App_112.php core/Database_110.php core/View_111.php core/helpers_109.php rm -f core/App_112.php core/Database_110.php core/View_111.php core/helpers_109.php
rm -rf prompts/ rm -rf prompts/
# ─── 4. CREATE CAPROVER APP (idempotent) ───────────────────────────────────── # ─── 4. GET CAPROVER JWT TOKEN ───────────────────────────────────────────────
info "Logging in to CapRover at ${CAPROVER_URL}..." info "Authenticating with CapRover API..."
caprover login \ TOKEN=$(curl -sf -X POST "${CAPROVER_URL}/api/v2/login" \
--caproverUrl "$CAPROVER_URL" \ -H "Content-Type: application/json" \
--caproverPassword "$CAPROVER_PASSWORD" \ -d "{\"password\":\"${CAPROVER_PASSWORD}\"}" \
--name "production" | grep -o '"token":"[^"]*"' | cut -d'"' -f4)
info "Creating CapRover app '${APP_NAME}' (skips if already exists)..." [ -z "$TOKEN" ] && error "Auth failed. Check CAPROVER_URL and CAPROVER_PASSWORD."
caprover api \ info "Authenticated OK."
--caproverUrl "$CAPROVER_URL" \
--caproverPassword "$CAPROVER_PASSWORD" \
--path "/v2/user/apps/appDefinitions/register" \
--method "POST" \
--data "{\"appName\":\"${APP_NAME}\",\"hasPersistentData\":false}" 2>/dev/null || true
# ─── 5. SET ENVIRONMENT VARIABLES ON THE CAPROVER APP ─────────────────────── # ─── 5. CREATE APP (idempotent — ignores error if already exists) ────────────
info "Setting environment variables..." info "Creating CapRover app '${APP_NAME}'..."
ENV_VARS=$(cat <<EOF curl -sf -X POST "${CAPROVER_URL}/api/v2/user/apps/appDefinitions/register" \
[ -H "Content-Type: application/json" \
{"key":"APP_DEBUG", "value":"false"}, -H "x-captain-auth: ${TOKEN}" \
{"key":"APP_URL", "value":"${APP_URL}"}, -d "{\"appName\":\"${APP_NAME}\",\"hasPersistentData\":false}" > /dev/null || true
{"key":"DB_HOST", "value":"${DB_HOST}"},
{"key":"DB_PORT", "value":"${DB_PORT}"},
{"key":"DB_NAME", "value":"${DB_NAME}"},
{"key":"DB_USER", "value":"${DB_USER}"},
{"key":"DB_PASS", "value":"${DB_PASS}"}
]
EOF
)
caprover api \
--caproverUrl "$CAPROVER_URL" \
--caproverPassword "$CAPROVER_PASSWORD" \
--path "/v2/user/apps/appDefinitions/update" \
--method "POST" \
--data "{\"appName\":\"${APP_NAME}\",\"envVars\":${ENV_VARS}}"
info "Environment variables set." # ─── 6. SET ENVIRONMENT VARIABLES ───────────────────────────────────────────
info "Setting environment variables..."
# ─── 6. ENABLE HTTPS ON THE APP ────────────────────────────────────────────── curl -sf -X POST "${CAPROVER_URL}/api/v2/user/apps/appDefinitions/update" \
info "Enabling HTTPS (Let's Encrypt)..." -H "Content-Type: application/json" \
caprover api \ -H "x-captain-auth: ${TOKEN}" \
--caproverUrl "$CAPROVER_URL" \ -d "{
--caproverPassword "$CAPROVER_PASSWORD" \ \"appName\": \"${APP_NAME}\",
--path "/v2/user/apps/appDefinitions/enablebasedomainssl" \ \"envVars\": [
--method "POST" \ {\"key\":\"APP_DEBUG\", \"value\":\"false\"},
--data "{\"appName\":\"${APP_NAME}\"}" 2>/dev/null || warn "HTTPS may already be enabled or domain not set yet." {\"key\":\"APP_URL\", \"value\":\"${APP_URL}\"},
{\"key\":\"DB_HOST\", \"value\":\"${DB_HOST}\"},
# ─── 7. DEPLOY ─────────────────────────────────────────────────────────────── {\"key\":\"DB_PORT\", \"value\":\"${DB_PORT}\"},
info "Packaging and deploying to CapRover..." {\"key\":\"DB_NAME\", \"value\":\"${DB_NAME}\"},
{\"key\":\"DB_USER\", \"value\":\"${DB_USER}\"},
{\"key\":\"DB_PASS\", \"value\":\"${DB_PASS}\"}
]
}" > /dev/null
info "Env vars set."
# ─── 7. ENABLE HTTPS ─────────────────────────────────────────────────────────
info "Enabling HTTPS..."
curl -sf -X POST "${CAPROVER_URL}/api/v2/user/apps/appDefinitions/enablebasedomainssl" \
-H "Content-Type: application/json" \
-H "x-captain-auth: ${TOKEN}" \
-d "{\"appName\":\"${APP_NAME}\"}" > /dev/null \
|| warn "HTTPS may already be enabled."
# ─── 8. DEPLOY ───────────────────────────────────────────────────────────────
info "Deploying to CapRover from current directory..."
caprover deploy \ caprover deploy \
--caproverUrl "$CAPROVER_URL" \ --caproverUrl "$CAPROVER_URL" \
--caproverPassword "$CAPROVER_PASSWORD" \ --caproverPassword "$CAPROVER_PASSWORD" \
--appName "$APP_NAME" \ --appName "$APP_NAME" \
--branch "main" --branch "main"
# ─── DONE ────────────────────────────────────────────────────────────────────
info "Deploy complete!" info "Deploy complete!"
echo "" echo ""
echo "─────────────────────────────────────────────" echo " App URL : ${APP_URL}"
echo " App URL : ${APP_URL}" echo " DB Host : ${DB_HOST}/${DB_NAME}"
echo " DB Pass : ${DB_PASS} ← SAVE THIS"
echo "─────────────────────────────────────────────"
echo "" echo ""
info "App is pointing to your existing DB at: ${DB_HOST}/${DB_NAME}"
warn "Make sure your DB server allows connections from the CapRover container IP."
# ─── CLEANUP ───────────────────────────────────────────────────────────────── # ─── CLEANUP ─────────────────────────────────────────────────────────────────
cd /tmp && rm -rf "$DEPLOY_DIR" cd /tmp && rm -rf "$DEPLOY_DIR"
......
#!/usr/bin/env bash
# =============================================================================
# Club Management System — Full CapRover Deploy Script
# Usage: chmod +x deploy.sh && ./deploy.sh
# =============================================================================
set -e
# ─── CONFIGURATION ───────────────────────────────────────────────────────────
CAPROVER_URL="http://captain.caprover.al-arcade.com"
CAPROVER_PASSWORD="Alarcade123#"
APP_NAME="club-management-club"
GITLAB_REPO="http://gitlab.caprover.al-arcade.com/root/finalclubmanagementphp.git"
GITLAB_USER="root"
GITLAB_TOKEN="vHATWUzqfUC1nkXkGkai"
# Existing DB server
DB_HOST="srv-captain--mysql-db"
DB_PORT="3306"
DB_NAME="club_management"
DB_USER="root"
DB_PASS="Alarcade123#"
APP_URL="https://${APP_NAME}.caprover.al-arcade.com"
# ─── COLORS ──────────────────────────────────────────────────────────────────
GREEN='\033[0;32m'; YELLOW='\033[1;33m'; RED='\033[0;31m'; NC='\033[0m'
info() { echo -e "${GREEN}[INFO]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
error() { echo -e "${RED}[ERROR]${NC} $*"; exit 1; }
# ─── 1. PREREQUISITES ────────────────────────────────────────────────────────
info "Checking prerequisites..."
if ! command -v node &>/dev/null; then
info "Installing Node.js 20..."
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y nodejs
fi
node -v
if ! command -v caprover &>/dev/null; then
info "Installing CapRover CLI..."
npm install -g caprover
fi
caprover --version
command -v git &>/dev/null || { apt-get update && apt-get install -y git; }
command -v curl &>/dev/null || { apt-get update && apt-get install -y curl; }
# ─── 2. CLONE REPO ───────────────────────────────────────────────────────────
DEPLOY_DIR="/tmp/club_deploy_$(date +%s)"
info "Cloning repository to ${DEPLOY_DIR}..."
git clone "http://${GITLAB_USER}:${GITLAB_TOKEN}@$(echo $GITLAB_REPO | sed 's|http://||')" "$DEPLOY_DIR"
cd "$DEPLOY_DIR"
# ─── 3. SAFETY CLEANUP ───────────────────────────────────────────────────────
info "Removing sensitive/dead files..."
rm -f code.sql
rm -f core/App_112.php core/Database_110.php core/View_111.php core/helpers_109.php
rm -rf prompts/
# ─── 4. GET CAPROVER JWT TOKEN ───────────────────────────────────────────────
info "Authenticating with CapRover API..."
TOKEN=$(curl -sf -X POST "${CAPROVER_URL}/api/v2/login" \
-H "Content-Type: application/json" \
-d "{\"password\":\"${CAPROVER_PASSWORD}\"}" \
| grep -o '"token":"[^"]*"' | cut -d'"' -f4)
[ -z "$TOKEN" ] && error "Auth failed. Check CAPROVER_URL and CAPROVER_PASSWORD."
info "Authenticated OK."
# ─── 5. CREATE APP (idempotent — ignores error if already exists) ────────────
info "Creating CapRover app '${APP_NAME}'..."
curl -sf -X POST "${CAPROVER_URL}/api/v2/user/apps/appDefinitions/register" \
-H "Content-Type: application/json" \
-H "x-captain-auth: ${TOKEN}" \
-d "{\"appName\":\"${APP_NAME}\",\"hasPersistentData\":false}" > /dev/null || true
# ─── 6. SET ENVIRONMENT VARIABLES ───────────────────────────────────────────
info "Setting environment variables..."
curl -sf -X POST "${CAPROVER_URL}/api/v2/user/apps/appDefinitions/update" \
-H "Content-Type: application/json" \
-H "x-captain-auth: ${TOKEN}" \
-d "{
\"appName\": \"${APP_NAME}\",
\"envVars\": [
{\"key\":\"APP_DEBUG\", \"value\":\"false\"},
{\"key\":\"APP_URL\", \"value\":\"${APP_URL}\"},
{\"key\":\"DB_HOST\", \"value\":\"${DB_HOST}\"},
{\"key\":\"DB_PORT\", \"value\":\"${DB_PORT}\"},
{\"key\":\"DB_NAME\", \"value\":\"${DB_NAME}\"},
{\"key\":\"DB_USER\", \"value\":\"${DB_USER}\"},
{\"key\":\"DB_PASS\", \"value\":\"${DB_PASS}\"}
]
}" > /dev/null
info "Env vars set."
# ─── 7. ENABLE HTTPS ─────────────────────────────────────────────────────────
info "Enabling HTTPS..."
curl -sf -X POST "${CAPROVER_URL}/api/v2/user/apps/appDefinitions/enablebasedomainssl" \
-H "Content-Type: application/json" \
-H "x-captain-auth: ${TOKEN}" \
-d "{\"appName\":\"${APP_NAME}\"}" > /dev/null \
|| warn "HTTPS may already be enabled."
# ─── 8. DEPLOY ───────────────────────────────────────────────────────────────
info "Deploying to CapRover from current directory..."
caprover deploy \
--caproverUrl "$CAPROVER_URL" \
--caproverPassword "$CAPROVER_PASSWORD" \
--appName "$APP_NAME" \
--branch "main"
# ─── DONE ────────────────────────────────────────────────────────────────────
info "Deploy complete!"
echo ""
echo " App URL : ${APP_URL}"
echo " DB Host : ${DB_HOST}/${DB_NAME}"
echo ""
# ─── CLEANUP ─────────────────────────────────────────────────────────────────
cd /tmp && rm -rf "$DEPLOY_DIR"
info "Temp files cleaned up."
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment