first commit
This commit is contained in:
102
.drone.yml
Normal file
102
.drone.yml
Normal file
@@ -0,0 +1,102 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: api-extranetwork
|
||||
|
||||
# Sadece main branch'te tetiklenir
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
|
||||
steps:
|
||||
# -------------------------------------------------------
|
||||
# 1. Bağımlılıkları kur
|
||||
# -------------------------------------------------------
|
||||
- name: composer-install
|
||||
image: composer:2.2
|
||||
volumes:
|
||||
- name: composer-cache
|
||||
path: /root/.composer/cache
|
||||
commands:
|
||||
- composer install --no-dev --optimize-autoloader --no-interaction --prefer-dist
|
||||
|
||||
# -------------------------------------------------------
|
||||
# 2. PHP Unit testlerini çalıştır
|
||||
# -------------------------------------------------------
|
||||
- name: tests
|
||||
image: php:7.3-cli
|
||||
commands:
|
||||
- apt-get update -qq
|
||||
- apt-get install -y --no-install-recommends libzip-dev libpng-dev libxml2-dev libonig-dev > /dev/null 2>&1
|
||||
- docker-php-ext-install pdo pdo_mysql zip mbstring > /dev/null 2>&1
|
||||
- cp .env.example .env
|
||||
- php artisan key:generate
|
||||
- vendor/bin/phpunit --no-coverage --stop-on-failure
|
||||
environment:
|
||||
DB_CONNECTION: sqlite
|
||||
DB_DATABASE: ":memory:"
|
||||
depends_on:
|
||||
- composer-install
|
||||
|
||||
# -------------------------------------------------------
|
||||
# 3. Docker image build & Gitea Container Registry'e push
|
||||
# -------------------------------------------------------
|
||||
- name: docker-build-push
|
||||
image: plugins/docker
|
||||
settings:
|
||||
registry: git.extranetwork.net
|
||||
repo: git.extranetwork.net/gitea/api-extranetwork
|
||||
username:
|
||||
from_secret: GITEA_USER
|
||||
password:
|
||||
from_secret: GITEA_TOKEN
|
||||
tags:
|
||||
- latest
|
||||
- ${DRONE_COMMIT_SHA:0:8}
|
||||
build_args:
|
||||
- APP_ENV=production
|
||||
depends_on:
|
||||
- tests
|
||||
when:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
|
||||
# -------------------------------------------------------
|
||||
# 4. SSH ile sunucuya deploy et
|
||||
# -------------------------------------------------------
|
||||
- name: deploy
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
host:
|
||||
from_secret: DEPLOY_HOST
|
||||
user:
|
||||
from_secret: DEPLOY_USER
|
||||
key:
|
||||
from_secret: DEPLOY_SSH_KEY
|
||||
port: 22
|
||||
script:
|
||||
- cd /opt/api.extranetwork.com
|
||||
- docker compose pull
|
||||
- docker compose up -d --remove-orphans
|
||||
- docker compose exec -T app php artisan migrate --force
|
||||
- docker compose exec -T app php artisan config:cache
|
||||
- docker compose exec -T app php artisan route:cache
|
||||
- docker compose exec -T app php artisan view:cache
|
||||
- echo "Deploy tamamlandı - $(date)"
|
||||
depends_on:
|
||||
- docker-build-push
|
||||
when:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
|
||||
# -------------------------------------------------------
|
||||
# Uçucu volume (composer cache pipeline içinde paylaşılır)
|
||||
# -------------------------------------------------------
|
||||
volumes:
|
||||
- name: composer-cache
|
||||
temp: {}
|
||||
Reference in New Issue
Block a user