From 4f2a435e2ae05eae79295f252cff5736dd0f684a Mon Sep 17 00:00:00 2001 From: webmaster Date: Sat, 20 Dec 2025 20:04:56 +0000 Subject: [PATCH] dev (#2) Co-authored-by: Frank John Begornia Reviewed-on: https://git.crewsportswear.app/webmaster/merchbay_admin/pulls/2 --- .dockerignore | 18 +++ .env.docker | 13 ++ .env.example | 26 ++-- .env.server.example | 23 ++++ .gitea/workflows/build-push.yml | 57 +++++++++ .gitea/workflows/deploy-dev.yml | 160 +++++++++++++++++++++++ .gitea/workflows/deploy.yml | 93 ++++++++++++++ Dockerfile | 71 +++++++++++ app/Providers/AppServiceProvider.php | 5 +- docker-compose.yml | 44 +++++++ readme.md | 181 ++++++++++++++++++++++++--- 11 files changed, 666 insertions(+), 25 deletions(-) create mode 100644 .dockerignore create mode 100644 .env.docker create mode 100644 .env.server.example create mode 100644 .gitea/workflows/build-push.yml create mode 100644 .gitea/workflows/deploy-dev.yml create mode 100644 .gitea/workflows/deploy.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..434a391 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,18 @@ +.git +.gitignore +.env +vendor +node_modules +storage/logs/* +storage/framework/cache/* +storage/framework/sessions/* +storage/framework/views/* +bootstrap/cache/* +tests +.editorconfig +.phpunit.result.cache +phpunit.xml +readme.md +docker-compose.yml +Dockerfile +.dockerignore diff --git a/.env.docker b/.env.docker new file mode 100644 index 0000000..e56d3f7 --- /dev/null +++ b/.env.docker @@ -0,0 +1,13 @@ +# Docker Environment Variables +# Copy this file and configure for your external MySQL database + +# Database Configuration - Update these to connect to your external MySQL +DB_HOST=your-mysql-host +DB_PORT=3306 +DB_DATABASE=merchbay_admin +DB_USERNAME=your-mysql-user +DB_PASSWORD=your-mysql-password + +# Application Configuration +APP_ENV=production +APP_DEBUG=false diff --git a/.env.example b/.env.example index 9a9d0dc..0b89503 100644 --- a/.env.example +++ b/.env.example @@ -1,25 +1,33 @@ -APP_ENV=local -APP_DEBUG=true -APP_KEY=SomeRandomString -APP_URL=http://localhost +# Application Configuration +APP_ENV=production +APP_DEBUG=false +APP_KEY=base64:YOUR_APP_KEY_HERE +APP_URL=https://merchbay.com +# Database Configuration - External MySQL DB_CONNECTION=mysql -DB_HOST=127.0.0.1 +DB_HOST=your-mysql-host DB_PORT=3306 -DB_DATABASE=homestead -DB_USERNAME=homestead -DB_PASSWORD=secret +DB_DATABASE=merchbay_admin +DB_USERNAME=your-mysql-user +DB_PASSWORD=your-mysql-password +# Traefik Domain Configuration +DOMAIN=merchbay.com + +# Cache & Session CACHE_DRIVER=file SESSION_DRIVER=file QUEUE_DRIVER=sync +# Redis (Optional) REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 +# Mail Configuration MAIL_DRIVER=smtp -MAIL_HOST=mailtrap.io +MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null diff --git a/.env.server.example b/.env.server.example new file mode 100644 index 0000000..1ce82cd --- /dev/null +++ b/.env.server.example @@ -0,0 +1,23 @@ +# Server .env file for Development Environment +# +# Instructions: +# 1. SSH to your server: ssh webmaster@YOUR_SERVER_IP +# 2. Create directory: mkdir -p /var/www/merchbay_admin_dev +# 3. Create this file: nano /var/www/merchbay_admin_dev/.env +# 4. Copy the content below (fill in YOUR_DB_PASSWORD) +# 5. Save and secure: chmod 600 /var/www/merchbay_admin_dev/.env + +APP_ENV=development +APP_DEBUG=true +APP_URL=https://dev-admin.merchbay.app +DB_HOST=mysql +DB_PORT=3306 +DB_DATABASE=merchcbay_db +DB_USERNAME=crewapp +DB_PASSWORD=YOUR_DB_PASSWORD_HERE +DOMAIN=dev-admin.merchbay.app + +# Notes: +# - DB_HOST=mysql (your MySQL container name on crew-app-net network) +# - Replace YOUR_DB_PASSWORD_HERE with your actual MySQL password +# - This file should NEVER be committed to git diff --git a/.gitea/workflows/build-push.yml b/.gitea/workflows/build-push.yml new file mode 100644 index 0000000..88b0bd8 --- /dev/null +++ b/.gitea/workflows/build-push.yml @@ -0,0 +1,57 @@ +name: Build and Push Docker Image + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + tag: + description: 'Docker image tag (e.g., v1.0.0, latest)' + required: false + default: 'latest' + push_to_registry: + description: 'Push to registry?' + required: false + default: 'true' + +jobs: + build-and-push: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Registry + uses: docker/login-action@v2 + with: + registry: ${{ secrets.DOCKER_REGISTRY_URL }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ secrets.DOCKER_REGISTRY_URL }}/merchbay_admin + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=raw,value=latest + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ secrets.DOCKER_REGISTRY_URL }}/merchbay_admin:buildcache + cache-to: type=registry,ref=${{ secrets.DOCKER_REGISTRY_URL }}/merchbay_admin:buildcache,mode=max diff --git a/.gitea/workflows/deploy-dev.yml b/.gitea/workflows/deploy-dev.yml new file mode 100644 index 0000000..681ec28 --- /dev/null +++ b/.gitea/workflows/deploy-dev.yml @@ -0,0 +1,160 @@ +name: Deploy Development + +on: + push: + branches: + - dev + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + + steps: + # 1️⃣ Checkout code + - name: Checkout code + shell: sh + run: | + git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git /workspace/repo + cd /workspace/repo + git checkout $GITHUB_REF_NAME + + # 2️⃣ Build image + - name: Build Docker image + shell: sh + run: | + cd /workspace/repo + docker build -t merchbay_admin:dev . + docker save merchbay_admin:dev | gzip > merchbay_admin_dev.tar.gz + + # 3️⃣ Setup SSH + - name: Setup SSH + shell: sh + env: + DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }} + DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} + run: | + mkdir -p ~/.ssh + chmod 700 ~/.ssh + echo "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts + + # 4️⃣ Upload artifacts + - name: Upload image and compose + shell: sh + env: + DEPLOY_USER: ${{ secrets.DEPLOY_USER }} + DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} + run: | + scp -i ~/.ssh/id_ed25519 \ + /workspace/repo/merchbay_admin_dev.tar.gz \ + /workspace/repo/docker-compose.yml \ + ${DEPLOY_USER}@${DEPLOY_HOST}:/tmp/ + + # 5️⃣ Deploy on server + - name: Deploy on server + shell: sh + env: + DEPLOY_USER: ${{ secrets.DEPLOY_USER }} + DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} + + run: | + ssh -i ~/.ssh/id_ed25519 $DEPLOY_USER@$DEPLOY_HOST << 'EOF' + set -e + + DEPLOY_DIR="/var/www/apps/merchbay_admin_dev" + mkdir -p "$DEPLOY_DIR" + + echo "📦 Loading image" + docker load < /tmp/merchbay_admin_dev.tar.gz + + echo "🧹 Removing old merchbay_admin images" + docker images | grep merchbay_admin | grep -v "$(docker images merchbay_admin:dev -q)" | awk '{print $3}' | xargs -r docker rmi -f || true + + echo "📄 Updating compose file" + cp /tmp/docker-compose.yml "$DEPLOY_DIR/" + + cd "$DEPLOY_DIR" + + echo "🔍 Checking .env file" + if [ ! -f .env ]; then + echo "❌ .env file not found at $DEPLOY_DIR/.env" + echo "Please create it first with required variables:" + echo " - DB_*, IMAGES_DIRECTORY, PRODUCTION_PRIVATE_SERVER" + exit 1 + fi + + echo "🔧 Fixing .env permissions" + sudo chown $USER:$USER .env + sudo chmod 600 .env + + echo "🌐 Ensure networks" + docker network inspect traefik-public >/dev/null 2>&1 || \ + docker network create traefik-public + docker network inspect crew-app-net >/dev/null 2>&1 || \ + docker network create crew-app-net + + echo "🚀 Starting containers (env vars from .env file)" + docker compose up -d + + echo "⏳ Waiting for app container" + sleep 15 + + if docker ps --format '{{.Names}}' | grep -q merchbay_admin_app; then + echo "🧹 Clearing and rebuilding config cache" + docker compose exec -T app php artisan config:clear + docker compose exec -T app php artisan config:cache + else + echo "❌ App container not running" + docker compose logs + exit 1 + fi + + echo "🧹 Cleanup" + rm -f /tmp/merchbay_admin_dev.tar.gz /tmp/docker-compose.yml + + echo "🧹 Aggressive Docker cleanup to reclaim space" + docker image prune -af --filter "until=24h" || true + docker container prune -f || true + docker volume prune -f || true + docker builder prune -af --filter "until=48h" || true + echo "📊 Docker space usage:" + docker system df + + echo "✅ Deployment completed" + EOF + + + # 6️⃣ Health check + - name: Health check + shell: sh + run: | + echo "⏳ Waiting for app to be ready..." + sleep 20 + + echo "🔍 Testing health check (ignoring SSL cert for now)..." + HTTP_CODE=$(curl -k -s -o /dev/null -w "%{http_code}" --max-time 30 https://dev-admin.merchbay.app || echo "000") + + if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "302" ] || [ "$HTTP_CODE" = "301" ]; then + echo "✅ Health check passed! (HTTP $HTTP_CODE)" + echo "⚠️ Note: Using -k to ignore SSL cert. Check Traefik logs if cert not ready." + else + echo "❌ Health check failed! (HTTP $HTTP_CODE)" + echo "" + echo "💡 Troubleshooting:" + echo " 1. Check if container is running:" + echo " docker ps | grep merchbay_admin_app" + echo "" + echo " 2. Check app logs:" + echo " docker logs merchbay_admin_app" + echo "" + echo " 3. Check Traefik logs:" + echo " docker logs traefik" + echo "" + echo " 4. Test manually:" + echo " curl -Ik https://dev-admin.merchbay.app" + exit 1 + fi \ No newline at end of file diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..3406a42 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,93 @@ +name: Deploy Production (admin.merchbay.app) + +on: + push: + branches: + - main + - master + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + + steps: + - name: Checkout code + shell: sh + run: | + git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git /workspace/repo || true + cd /workspace/repo + git fetch origin $GITHUB_REF_NAME + git checkout $GITHUB_REF_NAME + git pull origin $GITHUB_REF_NAME + + - name: Build Docker Image + shell: sh + run: | + cd /workspace/repo + docker build -t merchbay_admin:latest . + docker save merchbay_admin:latest | gzip > merchbay_admin.tar.gz + + - name: Setup SSH and Deploy + shell: sh + run: | + mkdir -p ~/.ssh + chmod 700 ~/.ssh + echo "$DEPLOY_SSH_KEY" > ~/.ssh/deploy_key + chmod 600 ~/.ssh/deploy_key + ssh-keygen -y -f ~/.ssh/deploy_key > /dev/null 2>&1 || { echo "Error: Invalid SSH key format"; exit 1; } + + cd /workspace/repo + scp -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key merchbay_admin.tar.gz docker-compose.yml "$DEPLOY_USER@$DEPLOY_HOST:/tmp/" + + ssh -o StrictHostKeyChecking=no -i ~/.ssh/deploy_key "$DEPLOY_USER@$DEPLOY_HOST" " + DEPLOY_DIR='/var/www/merchbay_admin' + mkdir -p \$DEPLOY_DIR + cd /tmp + docker load < merchbay_admin.tar.gz + + echo 'Removing old merchbay_admin images' + docker images | grep merchbay_admin | grep -v "\$(docker images merchbay_admin:latest -q)" | awk '{print \$3}' | xargs -r docker rmi -f || true + + cp docker-compose.yml \$DEPLOY_DIR/ + cd \$DEPLOY_DIR + + # .env file should already exist on server with all required variables + # Required: DB_*, IMAGES_DIRECTORY, PRODUCTION_PRIVATE_SERVER + # If it doesn't exist, deployment will fail (this is intentional for security) + + docker compose down || true + docker image prune -f + docker network inspect traefik-public >/dev/null 2>&1 || docker network create traefik-public + docker network inspect crew-app-net >/dev/null 2>&1 || docker network create crew-app-net + export DOMAIN=admin.merchbay.app + export APP_URL=https://admin.merchbay.app + docker compose up -d + sleep 10 + docker compose exec -T app php artisan config:cache + docker compose exec -T app php artisan route:cache + rm -f /tmp/merchbay_admin.tar.gz /tmp/docker-compose.yml + + echo 'Aggressive Docker cleanup to reclaim space' + docker image prune -af --filter "until=24h" || true + docker container prune -f || true + docker volume prune -f || true + docker builder prune -af --filter "until=48h" || true + echo 'Docker space usage:' + docker system df + + echo 'Production deployment completed successfully!' + echo 'Application available at: https://admin.merchbay.app' + " + env: + DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }} + DEPLOY_USER: ${{ secrets.DEPLOY_USER }} + DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} + + - name: Health Check + shell: sh + run: | + sleep 10 + curl -f https://admin.merchbay.app || exit 1 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fc01642 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,71 @@ +# Use PHP 7.4 with Apache (compatible with Laravel 5.2 and ARM64) +FROM php:7.4-apache + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git \ + curl \ + libpng-dev \ + libonig-dev \ + libxml2-dev \ + libzip-dev \ + zip \ + unzip \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + openssh-client \ + && docker-php-ext-configure gd --with-freetype --with-jpeg \ + && docker-php-ext-install -j$(nproc) gd + +# Install PHP extensions +RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath zip + +# Enable Apache mod_rewrite +RUN a2enmod rewrite + +# Install Composer +COPY --from=composer:1.10 /usr/bin/composer /usr/bin/composer + +# Set working directory +WORKDIR /var/www/html + +# Copy existing application directory contents +COPY . /var/www/html + +# Create storage directories and set permissions +RUN mkdir -p storage/framework/views \ + storage/framework/cache \ + storage/framework/sessions \ + storage/logs \ + bootstrap/cache + +# Set proper ownership and permissions +RUN chown -R www-data:www-data /var/www/html \ + && chmod -R 775 /var/www/html/storage \ + && chmod -R 775 /var/www/html/bootstrap/cache + +# Create .env file if it doesn't exist +RUN if [ ! -f .env ]; then cp .env.example .env; fi + +# Install PHP dependencies without running post-install scripts +RUN composer install --no-dev --no-scripts --no-interaction + +# Generate application key +RUN php artisan key:generate + +# Optimize autoloader +RUN composer dump-autoload --optimize --no-dev + +# Configure Apache DocumentRoot to point to Laravel's public directory +ENV APACHE_DOCUMENT_ROOT=/var/www/html/public +RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf +RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf + +# Suppress Apache ServerName warning +RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf + +# Expose port 80 +EXPOSE 80 + +# Start Apache +CMD ["apache2-foreground"] diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 31d4448..37d859a 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -16,7 +16,10 @@ class AppServiceProvider extends ServiceProvider */ public function boot() { - // + // Force HTTPS when behind a proxy (Traefik) + if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { + \URL::forceSchema('https'); + } Storage::extend('sftp', function ($app, $config) { return new Filesystem(new SftpAdapter($config)); diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..58298e7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,44 @@ +services: + app: + image: merchbay_admin:dev + container_name: merchbay_admin_app + restart: unless-stopped + environment: + - APP_ENV=${APP_ENV:-production} + - APP_DEBUG=${APP_DEBUG:-false} + - APP_URL=${APP_URL:-http://localhost} + - DB_CONNECTION=mysql + - DB_HOST=${DB_HOST} + - DB_PORT=${DB_PORT:-3306} + - DB_DATABASE=${DB_DATABASE} + - DB_USERNAME=${DB_USERNAME} + - DB_PASSWORD=${DB_PASSWORD} + - IMAGES_DIRECTORY=${IMAGES_DIRECTORY} + - PRODUCTION_PRIVATE_SERVER=${PRODUCTION_PRIVATE_SERVER} + volumes: + - ./storage:/var/www/html/storage + - ./public/uploads:/var/www/html/public/uploads + labels: + - "traefik.enable=true" + - "traefik.http.routers.merchbay-admin-dev.rule=Host(`dev-admin.merchbay.app`)" + - "traefik.http.routers.merchbay-admin-dev.entrypoints=websecure" + - "traefik.http.routers.merchbay-admin-dev.tls=true" + - "traefik.http.routers.merchbay-admin-dev.tls.certresolver=le" + - "traefik.http.services.merchbay-admin-dev.loadbalancer.server.port=80" + # HTTP to HTTPS redirect + - "traefik.http.routers.merchbay-admin-dev-http.rule=Host(`dev-admin.merchbay.app`)" + - "traefik.http.routers.merchbay-admin-dev-http.entrypoints=web" + - "traefik.http.routers.merchbay-admin-dev-http.middlewares=https-redirect" + - "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https" + networks: + - traefik-public + - crew-app-net + - default + +networks: + traefik-public: + external: true + crew-app-net: + external: true + default: + driver: bridge diff --git a/readme.md b/readme.md index 7f8816d..5f90076 100644 --- a/readme.md +++ b/readme.md @@ -1,27 +1,178 @@ -# Laravel PHP Framework +# MerchBay Admin Panel -[![Build Status](https://travis-ci.org/laravel/framework.svg)](https://travis-ci.org/laravel/framework) -[![Total Downloads](https://poser.pugx.org/laravel/framework/d/total.svg)](https://packagist.org/packages/laravel/framework) -[![Latest Stable Version](https://poser.pugx.org/laravel/framework/v/stable.svg)](https://packagist.org/packages/laravel/framework) -[![Latest Unstable Version](https://poser.pugx.org/laravel/framework/v/unstable.svg)](https://packagist.org/packages/laravel/framework) -[![License](https://poser.pugx.org/laravel/framework/license.svg)](https://packagist.org/packages/laravel/framework) +A comprehensive administration platform built with Laravel 5.2 for managing e-commerce operations, product catalogs, and customer relationships. -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, queueing, and caching. +## Overview -Laravel is accessible, yet powerful, providing tools needed for large, robust applications. A superb inversion of control container, expressive migration system, and tightly integrated unit testing support give you the tools you need to build any application with which you are tasked. +MerchBay Admin is a web-based administration interface designed to streamline business operations for custom merchandise and sportswear management. The platform provides robust tools for inventory control, order processing, and analytics. -## Official Documentation +## Technology Stack -Documentation for the framework can be found on the [Laravel website](http://laravel.com/docs). +- **Framework**: Laravel 5.2 +- **PHP Version**: 7.4 +- **Web Server**: Apache 2.4 +- **Database**: MySQL +- **Reverse Proxy**: Traefik with Let's Encrypt SSL +- **Containerization**: Docker & Docker Compose +- **CI/CD**: Gitea Actions -## Contributing +## Features -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions). +- User authentication and role-based access control +- Product and inventory management +- Order processing and tracking +- Customer relationship management +- Analytics and reporting dashboard +- RESTful API endpoints +- Secure HTTPS communication -## Security Vulnerabilities +## Requirements -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed. +- Docker Engine 20.10+ +- Docker Compose 2.0+ +- PHP 7.4 (for local development) +- Composer 1.x +- MySQL 5.7+ or MariaDB 10.3+ + +## Quick Start + +### Using Docker (Recommended) + +```bash +# Clone the repository +git clone +cd merchbay_admin + +# Copy environment file +cp .env.example .env + +# Configure your environment variables +vim .env + +# Build and start containers +docker-compose up -d + +# Install dependencies +docker exec merchbay_admin_app composer install + +# Generate application key +docker exec merchbay_admin_app php artisan key:generate + +# Run migrations +docker exec merchbay_admin_app php artisan migrate +``` + +### Local Development + +```bash +# Install PHP dependencies +composer install + +# Copy environment file +cp .env.example .env + +# Generate application key +php artisan key:generate + +# Configure database in .env file +# Run migrations +php artisan migrate + +# Start development server +php artisan serve +``` + +## Configuration + +### Environment Variables + +Key environment variables to configure: + +- `APP_URL` - Application URL (e.g., https://admin.merchbay.app) +- `DB_HOST` - Database host +- `DB_DATABASE` - Database name +- `DB_USERNAME` - Database username +- `DB_PASSWORD` - Database password + +### SSL/HTTPS Configuration + +The application uses Traefik as a reverse proxy with automatic Let's Encrypt SSL certificates. Ensure your DNS is properly configured and the following Traefik labels are set in `docker-compose.yml`. + +## Deployment + +This project includes automated CI/CD pipelines via Gitea Actions: + +- **Development**: Auto-deploys on push to `dev` branch +- **Production**: Auto-deploys on push to `main`/`master` branch +- **Manual Builds**: Trigger builds with custom tags + +Refer to [DEPLOYMENT.md](DEPLOYMENT.md) and [DEPLOYMENT-PORTAINER.md](DEPLOYMENT-PORTAINER.md) for detailed deployment instructions. + +## Project Structure + +``` +merchbay_admin/ +├── app/ # Application core files +│ ├── Http/ # Controllers, middleware, routes +│ ├── Models/ # Eloquent models +│ └── Providers/ # Service providers +├── config/ # Configuration files +├── database/ # Migrations and seeds +├── public/ # Public assets +├── resources/ # Views, assets, lang files +├── storage/ # Application storage +├── .gitea/workflows/ # CI/CD pipelines +└── docker-compose.yml # Docker configuration +``` + +## Development + +### Running Tests + +```bash +# Run PHPUnit tests +docker exec merchbay_admin_app vendor/bin/phpunit + +# Or locally +./vendor/bin/phpunit +``` + +### Artisan Commands + +```bash +# List all available commands +docker exec merchbay_admin_app php artisan list + +# Clear application cache +docker exec merchbay_admin_app php artisan cache:clear + +# Run database migrations +docker exec merchbay_admin_app php artisan migrate +``` + +## Security + +- All HTTP traffic is automatically redirected to HTTPS +- Environment variables are managed securely via `.env` files +- SQL injection prevention via Eloquent ORM +- CSRF protection enabled on all forms +- XSS protection via Blade templating + +For security vulnerabilities, please contact the development team directly. + +## Documentation + +Additional documentation is available: + +- [Docker Setup Guide](README-DOCKER.md) +- [Deployment Guide](DEPLOYMENT.md) +- [Portainer Deployment](DEPLOYMENT-PORTAINER.md) +- [Traefik SSL Configuration](TRAEFIK-SSL-CONFIG.md) + +## Support + +For issues, questions, or contributions, please contact the development team or open an issue in the repository. ## License -The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT). +This project is proprietary software. All rights reserved.