feat: deploy
This commit is contained in:
parent
cd5a52eaa3
commit
c174d671d3
|
|
@ -1,144 +1,70 @@
|
||||||
services:
|
name: Laravel CI-CD
|
||||||
app:
|
|
||||||
image: gitea.leonmorival.com/leon-morival/bemeal-api:latest
|
|
||||||
container_name: bemeal-app
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
depends_on:
|
on:
|
||||||
pgsql:
|
push:
|
||||||
condition: service_healthy
|
branches: ["main"]
|
||||||
redis:
|
|
||||||
condition: service_started
|
env:
|
||||||
|
REGISTRY: gitea.leonmorival.com
|
||||||
|
IMAGE_NAME: daily_meal/bemeal-api
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# TESTS
|
||||||
|
# =========================
|
||||||
|
test:
|
||||||
|
name: Tests Unitaires
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup PHP container tests
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-v $PWD:/app \
|
||||||
|
-w /app \
|
||||||
|
laravelsail/php84-composer:latest \
|
||||||
|
bash -c "composer install --no-interaction --ignore-platform-req=ext-intl && php artisan test"
|
||||||
|
|
||||||
|
|
||||||
environment:
|
# =========================
|
||||||
APP_NAME: "BeMeal"
|
# BUILD & PUSH IMAGE
|
||||||
APP_ENV: production
|
# =========================
|
||||||
APP_DEBUG: "false"
|
build:
|
||||||
APP_KEY: ${APP_KEY}
|
name: Build & Push Docker
|
||||||
APP_URL: ${APP_URL}
|
needs: test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
APP_LOCALE: fr
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
SERVER_NAME: ":80"
|
- name: Login to Gitea Registry
|
||||||
APP_RUNTIME: "Laravel\\FrankenPHP\\Runtime"
|
run: |
|
||||||
|
echo "${{ secrets.TOKEN_GITEA }}" \
|
||||||
|
| docker login $REGISTRY \
|
||||||
|
-u "${{ github.actor }}" \
|
||||||
|
--password-stdin
|
||||||
|
|
||||||
DB_CONNECTION: pgsql
|
- name: Build Docker image
|
||||||
DB_HOST: pgsql
|
run: |
|
||||||
DB_PORT: 5432
|
IMAGE=$REGISTRY/$IMAGE_NAME:latest
|
||||||
DB_DATABASE: ${DB_DATABASE}
|
docker build -t $IMAGE .
|
||||||
DB_USERNAME: ${DB_USERNAME}
|
docker push $IMAGE
|
||||||
DB_PASSWORD: ${DB_PASSWORD}
|
|
||||||
|
|
||||||
REDIS_HOST: redis
|
|
||||||
REDIS_CLIENT: predis
|
|
||||||
QUEUE_CONNECTION: redis
|
|
||||||
|
|
||||||
SCOUT_DRIVER: meilisearch
|
|
||||||
MEILISEARCH_HOST: http://meilisearch:7700
|
|
||||||
MEILISEARCH_KEY: ${MEILISEARCH_KEY}
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- bemeal_storage:/var/www/html/storage/app
|
|
||||||
- bemeal_public:/var/www/html/storage/app/public
|
|
||||||
|
|
||||||
networks:
|
|
||||||
- nginx
|
|
||||||
- internal
|
|
||||||
|
|
||||||
horizon:
|
|
||||||
image: gitea.leonmorival.com/leon-morival/bemeal-api:latest
|
|
||||||
container_name: bemeal-horizon
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
command: php artisan horizon
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
pgsql:
|
|
||||||
condition: service_healthy
|
|
||||||
redis:
|
|
||||||
condition: service_started
|
|
||||||
|
|
||||||
environment:
|
|
||||||
APP_ENV: production
|
|
||||||
APP_KEY: ${APP_KEY}
|
|
||||||
|
|
||||||
DB_CONNECTION: pgsql
|
|
||||||
DB_HOST: pgsql
|
|
||||||
DB_PORT: 5432
|
|
||||||
DB_DATABASE: ${DB_DATABASE}
|
|
||||||
DB_USERNAME: ${DB_USERNAME}
|
|
||||||
DB_PASSWORD: ${DB_PASSWORD}
|
|
||||||
|
|
||||||
REDIS_HOST: redis
|
|
||||||
REDIS_CLIENT: predis
|
|
||||||
QUEUE_CONNECTION: redis
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- bemeal_storage:/var/www/html/storage/app
|
|
||||||
|
|
||||||
networks:
|
|
||||||
- internal
|
|
||||||
|
|
||||||
|
|
||||||
pgsql:
|
# =========================
|
||||||
image: postgres:15-alpine
|
# DEPLOY
|
||||||
container_name: bemeal-pgsql
|
# =========================
|
||||||
restart: unless-stopped
|
deploy:
|
||||||
|
name: Deploy via Portainer
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
environment:
|
steps:
|
||||||
POSTGRES_DB: ${DB_DATABASE}
|
- name: Trigger Portainer webhook
|
||||||
POSTGRES_USER: ${DB_USERNAME}
|
run: |
|
||||||
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
curl -X POST "${{ secrets.PORTAINER_WEBHOOK_URL }}"
|
||||||
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME} -d ${DB_DATABASE}"]
|
|
||||||
interval: 5s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 10
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- bemeal_pgsql:/var/lib/postgresql/data
|
|
||||||
|
|
||||||
networks:
|
|
||||||
- internal
|
|
||||||
|
|
||||||
redis:
|
|
||||||
image: redis:alpine
|
|
||||||
container_name: bemeal-redis
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- bemeal_redis:/data
|
|
||||||
|
|
||||||
networks:
|
|
||||||
- internal
|
|
||||||
|
|
||||||
meilisearch:
|
|
||||||
image: getmeili/meilisearch:latest
|
|
||||||
container_name: bemeal-meilisearch
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
environment:
|
|
||||||
MEILI_NO_ANALYTICS: "true"
|
|
||||||
MEILI_MASTER_KEY: ${MEILISEARCH_KEY}
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- bemeal_meili:/meili_data
|
|
||||||
|
|
||||||
networks:
|
|
||||||
- internal
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
bemeal_pgsql:
|
|
||||||
bemeal_redis:
|
|
||||||
bemeal_storage:
|
|
||||||
bemeal_public:
|
|
||||||
bemeal_meili:
|
|
||||||
|
|
||||||
networks:
|
|
||||||
nginx:
|
|
||||||
external: true
|
|
||||||
|
|
||||||
internal:
|
|
||||||
driver: bridge
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue