From e8d21d22f8ca5e79eae49ba37f520b3d52325844 Mon Sep 17 00:00:00 2001 From: Frank John Begornia Date: Thu, 18 Dec 2025 16:30:14 +0800 Subject: [PATCH] Add local environment configuration and setup documentation for development --- .env.local | 36 +++++ LOCAL_DEVELOPMENT.md | 133 +++++++++++++++++++ docker-compose.local.yml | 81 +++++++++++ resources/views/user-layouts/index.blade.php | 48 ------- 4 files changed, 250 insertions(+), 48 deletions(-) create mode 100644 .env.local create mode 100644 LOCAL_DEVELOPMENT.md create mode 100644 docker-compose.local.yml diff --git a/.env.local b/.env.local new file mode 100644 index 0000000..ef7599d --- /dev/null +++ b/.env.local @@ -0,0 +1,36 @@ +APP_ENV=local +APP_DEBUG=true +APP_KEY=base64:YOUR_APP_KEY_HERE + +DB_HOST=db +DB_DATABASE=merchbay +DB_USERNAME=merchbay +DB_PASSWORD=secret +DB_PORT=3306 + +CACHE_DRIVER=file +SESSION_DRIVER=file +QUEUE_DRIVER=sync + +# Local mail (logs to storage/logs/laravel.log) +MAIL_DRIVER=log +MAIL_HOST=localhost +MAIL_PORT=1025 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null + +# Local URLs +APP_URL=http://localhost:8080 +PROD_PRIVATE=http://localhost:8080 +IMAGES_URL=http://localhost:8080 +UPLOAD_URL=http://localhost:8080/uploads/ + +# Test Captcha (for local dev) +CAPTCHA_SITE_KEY=test_key +CAPTCHA_SECRET_KEY=test_secret + +# Analytics (optional for local) +ANALYTICS_SITE_ID= +ANALYTICS_CLIENT_ID= +ANALYTICS_SERVICE_EMAIL= diff --git a/LOCAL_DEVELOPMENT.md b/LOCAL_DEVELOPMENT.md new file mode 100644 index 0000000..7f350d7 --- /dev/null +++ b/LOCAL_DEVELOPMENT.md @@ -0,0 +1,133 @@ +# Local Development Setup for Merchbay + +## Quick Start + +1. **Copy local environment file:** + ```bash + cp .env.local .env + ``` + +2. **Build and start containers:** + ```bash + docker-compose -f docker-compose.local.yml up -d --build + ``` + +3. **Generate application key:** + ```bash + docker exec merchbay_app_local php artisan key:generate + ``` + +4. **Run migrations:** + ```bash + docker exec merchbay_app_local php artisan migrate + ``` + +5. **Access the application:** + - **App:** http://localhost:8080 + - **phpMyAdmin:** http://localhost:8081 + - Username: `merchbay` + - Password: `secret` + +## Development Commands + +### View logs +```bash +# Application logs +docker exec merchbay_app_local tail -f storage/logs/laravel.log + +# Apache logs +docker logs -f merchbay_app_local +``` + +### Run artisan commands +```bash +docker exec merchbay_app_local php artisan [command] +``` + +### Access container shell +```bash +docker exec -it merchbay_app_local bash +``` + +### Database access +```bash +docker exec -it merchbay_db_local mysql -u merchbay -psecret merchbay +``` + +### Clear caches +```bash +docker exec merchbay_app_local php artisan cache:clear +docker exec merchbay_app_local php artisan config:clear +docker exec merchbay_app_local php artisan view:clear +``` + +### Stop containers +```bash +docker-compose -f docker-compose.local.yml down +``` + +### Stop and remove volumes (clean slate) +```bash +docker-compose -f docker-compose.local.yml down -v +``` + +## Debugging + +### Enable Xdebug (if needed) +Add to Dockerfile: +```dockerfile +RUN pecl install xdebug-2.9.8 && docker-php-ext-enable xdebug +``` + +### Check container status +```bash +docker-compose -f docker-compose.local.yml ps +``` + +### View all logs +```bash +docker-compose -f docker-compose.local.yml logs -f +``` + +## Hot Reload Development + +For live code changes without rebuilding: +- Code changes in `.php` files are reflected immediately (via volume mount) +- View changes are reflected immediately +- Config/route changes require cache clearing + +## Database Management + +### Import SQL dump +```bash +docker exec -i merchbay_db_local mysql -u merchbay -psecret merchbay < dump.sql +``` + +### Export database +```bash +docker exec merchbay_db_local mysqldump -u merchbay -psecret merchbay > dump.sql +``` + +## Troubleshooting + +### Permission issues +```bash +docker exec merchbay_app_local chown -R www-data:www-data storage bootstrap/cache +docker exec merchbay_app_local chmod -R 775 storage bootstrap/cache +``` + +### Reset everything +```bash +docker-compose -f docker-compose.local.yml down -v +docker rmi merchbay_app:local +rm .env +cp .env.local .env +docker-compose -f docker-compose.local.yml up -d --build +``` + +## Notes + +- The local setup uses a separate MySQL container +- All code changes are live-mounted for easy development +- Mail is logged to `storage/logs/laravel.log` instead of being sent +- phpMyAdmin is available for easy database management diff --git a/docker-compose.local.yml b/docker-compose.local.yml new file mode 100644 index 0000000..f49a4be --- /dev/null +++ b/docker-compose.local.yml @@ -0,0 +1,81 @@ +services: + db: + image: mariadb:10.6 + platform: linux/arm64 + container_name: merchbay_db_local + restart: unless-stopped + environment: + MYSQL_DATABASE: merchbay + MYSQL_ROOT_PASSWORD: root + MYSQL_USER: merchbay + MYSQL_PASSWORD: secret + ports: + - "3306:3306" + volumes: + - db_data:/var/lib/mysql + networks: + - merchbay-local + + app: + build: + context: . + dockerfile: Dockerfile + container_name: merchbay_app_local + restart: unless-stopped + ports: + - "8080:80" + environment: + - APP_ENV=local + - APP_DEBUG=true + - APP_URL=http://localhost:8080 + - DB_CONNECTION=mysql + - DB_HOST=db + - DB_PORT=3306 + - DB_DATABASE=merchbay + - DB_USERNAME=merchbay + - DB_PASSWORD=secret + - PROD_PRIVATE=http://localhost:8080 + - IMAGES_URL=http://localhost:8080 + - UPLOAD_URL=http://localhost:8080/uploads/ + - MAIL_DRIVER=log + - MAIL_HOST=localhost + - MAIL_PORT=1025 + - MAIL_USERNAME=null + - MAIL_PASSWORD=null + - MAIL_ENCRYPTION=null + - CAPTCHA_SITE_KEY=test_key + - CAPTCHA_SECRET_KEY=test_secret + - ANALYTICS_SITE_ID= + - ANALYTICS_CLIENT_ID= + - ANALYTICS_SERVICE_EMAIL= + volumes: + - ./:/var/www/html + - ./storage:/var/www/html/storage + - ./public/uploads:/var/www/html/public/uploads + depends_on: + - db + networks: + - merchbay-local + + phpmyadmin: + image: arm64v8/phpmyadmin + platform: linux/arm64 + container_name: merchbay_phpmyadmin + restart: unless-stopped + ports: + - "8081:80" + environment: + PMA_HOST: db + PMA_PORT: 3306 + MYSQL_ROOT_PASSWORD: root + depends_on: + - db + networks: + - merchbay-local + +networks: + merchbay-local: + driver: bridge + +volumes: + db_data: diff --git a/resources/views/user-layouts/index.blade.php b/resources/views/user-layouts/index.blade.php index 6e4057f..f67e559 100755 --- a/resources/views/user-layouts/index.blade.php +++ b/resources/views/user-layouts/index.blade.php @@ -86,54 +86,6 @@ - {{--
-
-
-
-

Total Sales

-
- - -
-
-
-
-
- - -
-
- - -
-
-
-
- -
-
- -
-
-
--}} @else