Merge pull request #25 from Aswajith7077/feat/add-landing #50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Zevrin Backend CI | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| backend_ci: | |
| name: Zevrin Backend - container & blob | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: backend | |
| services: | |
| mongo: | |
| image: mongo:7 | |
| ports: | |
| - 27017:27017 | |
| options: >- | |
| --health-cmd="mongosh --eval 'db.runCommand({ ping: 1 })'" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=5 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup environment | |
| run: | | |
| cat << EOF > .env | |
| DB_USER=admin | |
| DB_PASSWORD=password | |
| DB_HOST=mongo | |
| DB_NAME=zevrin_test | |
| MONGODB_URL=mongodb://mongo:27017/zevrin_test | |
| DEBUG=1 | |
| FRONT_END_PROD_URL=http://localhost:3000 | |
| FRONT_END_DEV_URL=http://localhost:3000 | |
| COLLECTION_PRODUCTS=products | |
| COLLECTION_USER=users | |
| COLLECTION_CART=cart | |
| COLLECTION_PROMOTION=promotions | |
| COLLECTION_BANNERS=banners | |
| COLLECTION_CATEGORIES=categories | |
| JWT_ENCODE_ALGORITHM=HS256 | |
| JWT_ACCESS_TOKEN_SECRET_KEY=${JWT_ACCESS_KEY} | |
| JWT_REFRESH_TOKEN_SECRET_KEY=${JWT_REFRESH_KEY} | |
| JWT_ACCESS_TOKEN_EXPIRE_TIME_MINUTES=30 | |
| JWT_REFRESH_TOKEN_EXPIRE_TIME_MINUTES=10080 | |
| MINIO_PORT=9000 | |
| MINIO_ROOT_USER=minioadmin | |
| MINIO_ROOT_PASSWORD=minioadmin | |
| MINIO_SERVER=http://minio:9000 | |
| MINIO_PROD_SERVER=http://minio:9000 | |
| EOF | |
| - name: Build backend Docker image | |
| run: docker build -t my-app-backend:${{ github.sha }} . | |
| - name: Create Docker network | |
| run: docker network create app-network || true | |
| - name: Start MinIO manually | |
| run: | | |
| docker run -d --name minio \ | |
| --network app-network \ | |
| -p 9000:9000 -p 9001:9001 \ | |
| -e MINIO_ROOT_USER=minioadmin \ | |
| -e MINIO_ROOT_PASSWORD=minioadmin \ | |
| quay.io/minio/minio:latest \ | |
| server /data --console-address :9001 | |
| - name: Verify MinIO is running | |
| run: | | |
| echo "Checking MinIO health..." | |
| for i in {1..10}; do | |
| if curl -sSf http://localhost:9000/minio/health/live > /dev/null; then | |
| echo "✅ MinIO is live!" | |
| exit 0 | |
| fi | |
| echo "Waiting for MinIO... attempt $i" | |
| sleep 3 | |
| done | |
| echo "❌ MinIO did not start in time" | |
| exit 1 | |
| - name: Verify backend container starts | |
| run: | | |
| docker run -d --name backend-test \ | |
| --network app-network \ | |
| -p 8000:8000 \ | |
| --env-file .env \ | |
| my-app-backend:${{ github.sha }} | |
| echo "Waiting for API to become ready..." | |
| for i in {1..30}; do | |
| if ! docker ps | grep -q backend-test; then | |
| echo "Container stopped unexpectedly. Logs:" | |
| docker logs backend-test | |
| exit 1 | |
| fi | |
| if curl -sSf http://localhost:8000/docs > /dev/null 2>&1; then | |
| echo "✅ API and MinIO connection verified!" | |
| exit 0 | |
| fi | |
| sleep 2 | |
| done | |
| echo "Container logs:" | |
| docker logs backend-test | |
| exit 1 |