Compare commits
1 Commits
test
...
55711a88ef
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55711a88ef |
34
.drone.yml
34
.drone.yml
@@ -1,15 +1,29 @@
|
|||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: bogazici-api
|
name: default
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
|
||||||
- push
|
|
||||||
branch:
|
branch:
|
||||||
|
- develop
|
||||||
- test
|
- test
|
||||||
- main
|
- main
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: laravel-check
|
||||||
|
image: php:8.4-cli
|
||||||
|
when:
|
||||||
|
branch:
|
||||||
|
- develop
|
||||||
|
commands:
|
||||||
|
- apt-get update && apt-get install -y git unzip curl libzip-dev default-mysql-client
|
||||||
|
- docker-php-ext-install pdo_mysql zip
|
||||||
|
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
- cp .env.example .env || true
|
||||||
|
- composer install --no-interaction --prefer-dist --optimize-autoloader
|
||||||
|
- php artisan key:generate --force || true
|
||||||
|
- php artisan config:clear || true
|
||||||
|
- php artisan test || true
|
||||||
|
|
||||||
- name: deploy-test
|
- name: deploy-test
|
||||||
image: appleboy/drone-ssh
|
image: appleboy/drone-ssh
|
||||||
when:
|
when:
|
||||||
@@ -17,12 +31,11 @@ steps:
|
|||||||
- test
|
- test
|
||||||
settings:
|
settings:
|
||||||
host:
|
host:
|
||||||
from_secret: SERVER_HOST
|
from_secret: server_host
|
||||||
username:
|
username:
|
||||||
from_secret: SERVER_USER
|
from_secret: server_user
|
||||||
key:
|
key:
|
||||||
from_secret: SERVER_SSH_KEY
|
from_secret: server_ssh_key
|
||||||
port: 22
|
|
||||||
script:
|
script:
|
||||||
- cd /opt/projects/bogazici/corporate-api/test/api
|
- cd /opt/projects/bogazici/corporate-api/test/api
|
||||||
- bash scripts/deploy-test.sh
|
- bash scripts/deploy-test.sh
|
||||||
@@ -34,12 +47,11 @@ steps:
|
|||||||
- main
|
- main
|
||||||
settings:
|
settings:
|
||||||
host:
|
host:
|
||||||
from_secret: SERVER_HOST
|
from_secret: server_host
|
||||||
username:
|
username:
|
||||||
from_secret: SERVER_USER
|
from_secret: server_user
|
||||||
key:
|
key:
|
||||||
from_secret: SERVER_SSH_KEY
|
from_secret: server_ssh_key
|
||||||
port: 22
|
|
||||||
script:
|
script:
|
||||||
- cd /opt/projects/bogazici/corporate-api/prod/api
|
- cd /opt/projects/bogazici/corporate-api/prod/api
|
||||||
- bash scripts/deploy-prod.sh
|
- bash scripts/deploy-prod.sh
|
||||||
|
|||||||
131
README.md
131
README.md
@@ -1,112 +1,59 @@
|
|||||||
# Boğaziçi Denizcilik API
|
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
||||||
|
|
||||||
Boğaziçi Denizcilik kurumsal web sitesi ve yönetim paneli için geliştirilmiş REST API backend uygulamasıdır.
|
<p align="center">
|
||||||
|
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
## Teknoloji
|
## About Laravel
|
||||||
|
|
||||||
- **PHP** 8.4 / **Laravel** 12
|
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||||
- **MySQL** (Eloquent ORM)
|
|
||||||
- **Laravel Sanctum** — API token tabanlı kimlik doğrulama
|
|
||||||
- **Spatie Permission** — Rol ve yetki yönetimi (RBAC)
|
|
||||||
- **Spatie ActivityLog** — Model değişiklik takibi
|
|
||||||
- **L5-Swagger** — OpenAPI/Swagger API dokümantasyonu
|
|
||||||
- **Pest** 4 / **PHPUnit** 12 — Test
|
|
||||||
- **Laravel Pint** — Kod formatlama
|
|
||||||
- **Docker** + **Apache** — Konteyner tabanlı deployment
|
|
||||||
- **Drone CI** — CI/CD pipeline
|
|
||||||
|
|
||||||
## Mimari
|
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||||
|
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||||
|
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||||
|
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||||
|
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||||
|
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||||
|
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||||
|
|
||||||
Proje **Repository + DTO + Action** pattern'i kullanır:
|
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||||
|
|
||||||
```
|
## Learning Laravel
|
||||||
app/
|
|
||||||
├── Actions/ # İş mantığı (Create, Update, Delete)
|
|
||||||
├── DTOs/ # Veri transfer nesneleri
|
|
||||||
├── Http/
|
|
||||||
│ ├── Controllers/
|
|
||||||
│ │ ├── Api/Admin/ # Yönetim paneli API (auth gerekli)
|
|
||||||
│ │ └── Api/V1/ # Public API v1
|
|
||||||
│ ├── Requests/ # Form doğrulama
|
|
||||||
│ └── Resources/ # API response dönüştürücüler
|
|
||||||
├── Models/ # Eloquent modeller
|
|
||||||
├── Repositories/ # Veri erişim katmanı (Contracts + Eloquent)
|
|
||||||
└── Concerns/ # Tekrar kullanılabilir trait'ler
|
|
||||||
```
|
|
||||||
|
|
||||||
## API Yapısı
|
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. You can also check out [Laravel Learn](https://laravel.com/learn), where you will be guided through building a modern Laravel application.
|
||||||
|
|
||||||
### Public API (`/api/v1`)
|
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||||
|
|
||||||
| Endpoint | Açıklama |
|
## Laravel Sponsors
|
||||||
|----------|----------|
|
|
||||||
| `GET /categories` | Kurs kategorileri |
|
|
||||||
| `GET /courses` | Kurslar (filtreleme, arama, sayfalama) |
|
|
||||||
| `GET /schedules` | Kurs programları |
|
|
||||||
| `GET /announcements` | Duyurular |
|
|
||||||
| `GET /hero-slides` | Anasayfa slider |
|
|
||||||
| `GET /faqs` | Sıkça sorulan sorular |
|
|
||||||
| `GET /menus/{location}` | Menüler |
|
|
||||||
| `GET /pages/{slug}` | Statik sayfalar |
|
|
||||||
| `GET /stories` | Başarı hikayeleri |
|
|
||||||
| `GET /settings` | Site ayarları |
|
|
||||||
| `GET /guide-cards` | Eğitim rehber kartları |
|
|
||||||
| `GET /sitemap-data` | SEO sitemap verisi |
|
|
||||||
| `POST /leads` | İletişim formu (rate limited) |
|
|
||||||
| `POST /comments` | Yorum gönderimi (rate limited) |
|
|
||||||
|
|
||||||
### Admin API (`/api/admin`)
|
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
|
||||||
|
|
||||||
Sanctum token ile korunan yönetim endpointleri:
|
### Premium Partners
|
||||||
|
|
||||||
- **Kimlik doğrulama:** `login`, `logout`, `me`
|
- **[Vehikl](https://vehikl.com)**
|
||||||
- **İçerik yönetimi:** Kurslar, kategoriler, programlar, duyurular, sayfalar, slider, FAQ, hikayeler
|
- **[Tighten Co.](https://tighten.co)**
|
||||||
- **Kullanıcı yönetimi:** Kullanıcılar, roller, yetkiler
|
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||||
- **Sistem:** Ayarlar, dosya yükleme, önizleme tokenları, önbellek temizleme
|
- **[64 Robots](https://64robots.com)**
|
||||||
|
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
|
||||||
|
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
|
||||||
|
- **[Redberry](https://redberry.international/laravel-development)**
|
||||||
|
- **[Active Logic](https://activelogic.com)**
|
||||||
|
|
||||||
API dokümantasyonu: `/api/documentation` (Swagger UI)
|
## Contributing
|
||||||
|
|
||||||
## Kurulum
|
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||||
|
|
||||||
```bash
|
## Code of Conduct
|
||||||
# Bağımlılıkları yükle
|
|
||||||
composer install
|
|
||||||
npm install
|
|
||||||
|
|
||||||
# Ortam dosyasını hazırla
|
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||||
cp .env.example .env
|
|
||||||
php artisan key:generate
|
|
||||||
|
|
||||||
# Veritabanını oluştur ve seed et
|
## Security Vulnerabilities
|
||||||
php artisan migrate --seed
|
|
||||||
|
|
||||||
# Geliştirme sunucusu (Laravel Herd ile)
|
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||||
# Site otomatik olarak https://bogazici-api.test adresinde erişilebilir
|
|
||||||
```
|
|
||||||
|
|
||||||
## Geliştirme
|
## License
|
||||||
|
|
||||||
```bash
|
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||||
# Testleri çalıştır
|
|
||||||
composer test
|
|
||||||
|
|
||||||
# Belirli bir testi çalıştır
|
|
||||||
php artisan test --compact --filter=testName
|
|
||||||
|
|
||||||
# Kod formatlama
|
|
||||||
vendor/bin/pint --dirty
|
|
||||||
|
|
||||||
# API route listesi
|
|
||||||
php artisan route:list --path=api
|
|
||||||
```
|
|
||||||
|
|
||||||
## Deployment
|
|
||||||
|
|
||||||
Drone CI ile otomatik deployment yapılır:
|
|
||||||
|
|
||||||
| Branch | Ortam | Yol |
|
|
||||||
|--------|-------|-----|
|
|
||||||
| `test` | Test | `/opt/projects/bogazici/corporate-api/test/api` |
|
|
||||||
| `main` | Production | `/opt/projects/bogazici/corporate-api/prod/api` |
|
|
||||||
|
|
||||||
Deployment Docker container içinde çalışır ve `scripts/deploy-test.sh` / `scripts/deploy-prod.sh` scriptleri kullanılır.
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ use App\Repositories\Eloquent\UserRepository;
|
|||||||
use Illuminate\Cache\RateLimiting\Limit;
|
use Illuminate\Cache\RateLimiting\Limit;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\RateLimiter;
|
use Illuminate\Support\Facades\RateLimiter;
|
||||||
use Illuminate\Support\Facades\URL;
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@@ -40,8 +39,6 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
/**
|
/**
|
||||||
* @var array<class-string, class-string>
|
* @var array<class-string, class-string>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public array $bindings = [
|
public array $bindings = [
|
||||||
CategoryRepositoryInterface::class => CategoryRepository::class,
|
CategoryRepositoryInterface::class => CategoryRepository::class,
|
||||||
CourseRepositoryInterface::class => CourseRepository::class,
|
CourseRepositoryInterface::class => CourseRepository::class,
|
||||||
@@ -71,8 +68,6 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
URL::forceScheme('https');
|
|
||||||
|
|
||||||
Str::macro('turkishSlug', function (string $text, string $separator = '-'): string {
|
Str::macro('turkishSlug', function (string $text, string $separator = '-'): string {
|
||||||
$map = [
|
$map = [
|
||||||
'ç' => 'c',
|
'ç' => 'c',
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ return Application::configure(basePath: dirname(__DIR__))
|
|||||||
apiPrefix: 'api',
|
apiPrefix: 'api',
|
||||||
)
|
)
|
||||||
->withMiddleware(function (Middleware $middleware): void {
|
->withMiddleware(function (Middleware $middleware): void {
|
||||||
|
$middleware->trustProxies(at: '*');
|
||||||
|
|
||||||
$middleware->statefulApi();
|
$middleware->statefulApi();
|
||||||
|
|
||||||
$middleware->throttleApi('60,1');
|
$middleware->throttleApi('60,1');
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ return [
|
|||||||
env('FRONTEND_URL', 'http://localhost:3000'),
|
env('FRONTEND_URL', 'http://localhost:3000'),
|
||||||
env('ADMIN_URL', 'http://localhost:3001'),
|
env('ADMIN_URL', 'http://localhost:3001'),
|
||||||
'http://localhost:5173',
|
'http://localhost:5173',
|
||||||
'https://admin.test.bogazicidenizcilik.com',
|
|
||||||
'https://test.bogazicidenizcilik.com',
|
|
||||||
],
|
],
|
||||||
|
|
||||||
'allowed_origins_patterns' => [],
|
'allowed_origins_patterns' => [],
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
name: bogazici-api-prod
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
bdc-api-prod:
|
bdc-api-prod:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
container_name: bdc-api-prod
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/var/www/html
|
- ./:/var/www/html
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
name: bogazici-api-test
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
bdc-api-test:
|
bdc-api-test:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
container_name: bdc-api-test
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/var/www/html
|
- ./:/var/www/html
|
||||||
|
|||||||
@@ -6,19 +6,17 @@ ENV_SOURCE="/opt/projects/bogazici/corporate-api/prod/.env.prod"
|
|||||||
BRANCH="main"
|
BRANCH="main"
|
||||||
CONTAINER="bdc-api-prod"
|
CONTAINER="bdc-api-prod"
|
||||||
COMPOSE_FILE="docker-compose.prod.yml"
|
COMPOSE_FILE="docker-compose.prod.yml"
|
||||||
COMPOSE_PROJECT="bogazici-api-prod"
|
|
||||||
UPLOADS_DIR="/opt/projects/bogazici/corporate-api/prod/uploads"
|
UPLOADS_DIR="/opt/projects/bogazici/corporate-api/prod/uploads"
|
||||||
|
|
||||||
echo "🚀 [API] Production deploy başlatılıyor..."
|
echo "🚀 [API] Production deploy başlatılıyor..."
|
||||||
|
|
||||||
cd "$PROJECT_DIR"
|
cd "$PROJECT_DIR"
|
||||||
|
|
||||||
git config --global --add safe.directory "$PROJECT_DIR" || true
|
sudo chown -R "$USER":www-data storage bootstrap/cache 2>/dev/null || true
|
||||||
|
sudo find storage -type d -exec chmod 2775 {} \; 2>/dev/null || true
|
||||||
find storage -type d -exec chmod 2775 {} \; 2>/dev/null || true
|
sudo find storage -type f -exec chmod 664 {} \; 2>/dev/null || true
|
||||||
find storage -type f -exec chmod 664 {} \; 2>/dev/null || true
|
sudo find bootstrap/cache -type d -exec chmod 2775 {} \; 2>/dev/null || true
|
||||||
find bootstrap/cache -type d -exec chmod 2775 {} \; 2>/dev/null || true
|
sudo find bootstrap/cache -type f -exec chmod 664 {} \; 2>/dev/null || true
|
||||||
find bootstrap/cache -type f -exec chmod 664 {} \; 2>/dev/null || true
|
|
||||||
|
|
||||||
git fetch origin
|
git fetch origin
|
||||||
git checkout "$BRANCH"
|
git checkout "$BRANCH"
|
||||||
@@ -37,35 +35,23 @@ if ! grep -q '^APP_KEY=base64:' .env; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sudo mkdir -p "$UPLOADS_DIR"/{images,videos,hero-slides,settings,pages,courses,announcements,categories}
|
||||||
|
sudo chown -R "$USER":www-data "$UPLOADS_DIR" 2>/dev/null || true
|
||||||
|
sudo find "$UPLOADS_DIR" -type d -exec chmod 2775 {} \; 2>/dev/null || true
|
||||||
|
sudo find "$UPLOADS_DIR" -type f -exec chmod 664 {} \; 2>/dev/null || true
|
||||||
|
|
||||||
mkdir -p "$UPLOADS_DIR"
|
docker stop "$CONTAINER" 2>/dev/null || true
|
||||||
chmod 2775 "$UPLOADS_DIR" 2>/dev/null || true
|
docker rm "$CONTAINER" 2>/dev/null || true
|
||||||
|
docker compose -f "$COMPOSE_FILE" down --remove-orphans 2>/dev/null || true
|
||||||
|
docker compose -f "$COMPOSE_FILE" up -d --build
|
||||||
|
|
||||||
docker rm -f bogazici-api-prod-bdc-api-prod-1 2>/dev/null || true
|
sleep 3
|
||||||
docker rm -f bdc-api-prod 2>/dev/null || true
|
docker compose -f "$COMPOSE_FILE" exec -T "$CONTAINER" composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev || true
|
||||||
|
docker compose -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan migrate --force || true
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" down --remove-orphans || true
|
docker compose -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan optimize:clear || true
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" up -d --build
|
docker compose -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan config:cache || true
|
||||||
|
docker compose -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan route:cache || true
|
||||||
echo "⏳ Container hazır olması bekleniyor..."
|
docker compose -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan view:cache || true
|
||||||
for i in {1..30}; do
|
|
||||||
if docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" ps --status running | grep -q "$CONTAINER"; then
|
|
||||||
echo "✅ Container ayakta"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
if [ "$i" -eq 30 ]; then
|
|
||||||
echo "❌ HATA: Container zamanında ayağa kalkmadı"
|
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" logs --tail=100
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" exec -T "$CONTAINER" composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
|
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan optimize:clear
|
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan config:cache
|
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan route:cache
|
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan view:cache
|
|
||||||
|
|
||||||
docker image prune -f 2>/dev/null || true
|
docker image prune -f 2>/dev/null || true
|
||||||
|
|
||||||
|
|||||||
@@ -6,19 +6,17 @@ ENV_SOURCE="/opt/projects/bogazici/corporate-api/test/.env.test"
|
|||||||
BRANCH="test"
|
BRANCH="test"
|
||||||
CONTAINER="bdc-api-test"
|
CONTAINER="bdc-api-test"
|
||||||
COMPOSE_FILE="docker-compose.test.yml"
|
COMPOSE_FILE="docker-compose.test.yml"
|
||||||
COMPOSE_PROJECT="bogazici-api-test"
|
|
||||||
UPLOADS_DIR="/opt/projects/bogazici/corporate-api/test/uploads"
|
UPLOADS_DIR="/opt/projects/bogazici/corporate-api/test/uploads"
|
||||||
|
|
||||||
echo "🚀 [API] Test deploy başlatılıyor..."
|
echo "🚀 [API] Test deploy başlatılıyor..."
|
||||||
|
|
||||||
cd "$PROJECT_DIR"
|
cd "$PROJECT_DIR"
|
||||||
|
|
||||||
git config --global --add safe.directory "$PROJECT_DIR" || true
|
sudo chown -R "$USER":www-data storage bootstrap/cache 2>/dev/null || true
|
||||||
|
sudo find storage -type d -exec chmod 2775 {} \; 2>/dev/null || true
|
||||||
find storage -type d -exec chmod 2775 {} \; 2>/dev/null || true
|
sudo find storage -type f -exec chmod 664 {} \; 2>/dev/null || true
|
||||||
find storage -type f -exec chmod 664 {} \; 2>/dev/null || true
|
sudo find bootstrap/cache -type d -exec chmod 2775 {} \; 2>/dev/null || true
|
||||||
find bootstrap/cache -type d -exec chmod 2775 {} \; 2>/dev/null || true
|
sudo find bootstrap/cache -type f -exec chmod 664 {} \; 2>/dev/null || true
|
||||||
find bootstrap/cache -type f -exec chmod 664 {} \; 2>/dev/null || true
|
|
||||||
|
|
||||||
git fetch origin
|
git fetch origin
|
||||||
git checkout "$BRANCH"
|
git checkout "$BRANCH"
|
||||||
@@ -37,35 +35,23 @@ if ! grep -q '^APP_KEY=base64:' .env; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$UPLOADS_DIR"
|
sudo mkdir -p "$UPLOADS_DIR"/{images,videos,hero-slides,settings,pages,courses,announcements,categories}
|
||||||
chmod 2775 "$UPLOADS_DIR" 2>/dev/null || true
|
sudo chown -R "$USER":www-data "$UPLOADS_DIR" 2>/dev/null || true
|
||||||
|
sudo find "$UPLOADS_DIR" -type d -exec chmod 2775 {} \; 2>/dev/null || true
|
||||||
|
sudo find "$UPLOADS_DIR" -type f -exec chmod 664 {} \; 2>/dev/null || true
|
||||||
|
|
||||||
docker rm -f bogazici-api-test-bdc-api-test-1 2>/dev/null || true
|
docker stop "$CONTAINER" 2>/dev/null || true
|
||||||
docker rm -f bdc-api-test 2>/dev/null || true
|
docker rm "$CONTAINER" 2>/dev/null || true
|
||||||
|
docker compose -f "$COMPOSE_FILE" down --remove-orphans 2>/dev/null || true
|
||||||
|
docker compose -f "$COMPOSE_FILE" up -d --build
|
||||||
|
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" down --remove-orphans || true
|
sleep 3
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" up -d --build
|
docker compose -f "$COMPOSE_FILE" exec -T "$CONTAINER" composer install --no-interaction --prefer-dist --optimize-autoloader || true
|
||||||
|
docker compose -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan migrate --force || true
|
||||||
|
docker compose -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan optimize:clear || true
|
||||||
echo "⏳ Container hazır olması bekleniyor..."
|
docker compose -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan config:cache || true
|
||||||
for i in {1..30}; do
|
docker compose -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan route:cache || true
|
||||||
if docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" ps --status running | grep -q "$CONTAINER"; then
|
docker compose -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan view:cache || true
|
||||||
echo "✅ Container ayakta"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
if [ "$i" -eq 30 ]; then
|
|
||||||
echo "❌ HATA: Container zamanında ayağa kalkmadı"
|
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" logs --tail=100
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" exec -T "$CONTAINER" composer install --no-interaction --prefer-dist --optimize-autoloader
|
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan optimize:clear
|
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan config:cache
|
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan route:cache
|
|
||||||
docker compose -p "$COMPOSE_PROJECT" -f "$COMPOSE_FILE" exec -T "$CONTAINER" php artisan view:cache
|
|
||||||
|
|
||||||
docker image prune -f 2>/dev/null || true
|
docker image prune -f 2>/dev/null || true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user