Initial update to use Docker-in-Docker for CI
Some checks are pending
CI/CD Pipeline (DinD) / Test Backend (DinD) (push) Waiting to run
CI/CD Pipeline (DinD) / Test Frontend (DinD) (push) Waiting to run
CI/CD Pipeline (DinD) / Build and Push Docker Images (DinD) (push) Blocked by required conditions
CI/CD Pipeline (DinD) / Deploy to Production (push) Blocked by required conditions
Some checks are pending
CI/CD Pipeline (DinD) / Test Backend (DinD) (push) Waiting to run
CI/CD Pipeline (DinD) / Test Frontend (DinD) (push) Waiting to run
CI/CD Pipeline (DinD) / Build and Push Docker Images (DinD) (push) Blocked by required conditions
CI/CD Pipeline (DinD) / Deploy to Production (push) Blocked by required conditions
This commit is contained in:
parent
1187f7b7a4
commit
a59a7c0e74
2 changed files with 617 additions and 172 deletions
|
@ -1,4 +1,4 @@
|
|||
name: CI/CD Pipeline
|
||||
name: CI/CD Pipeline (DinD)
|
||||
|
||||
on:
|
||||
push:
|
||||
|
@ -12,8 +12,8 @@ env:
|
|||
|
||||
jobs:
|
||||
test-backend:
|
||||
name: Test Backend
|
||||
runs-on: ubuntu-latest
|
||||
name: Test Backend (DinD)
|
||||
runs-on: [self-hosted, dind]
|
||||
|
||||
services:
|
||||
postgres:
|
||||
|
@ -33,6 +33,18 @@ jobs:
|
|||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup DinD environment
|
||||
run: |
|
||||
# Ensure DinD is running and accessible
|
||||
docker version
|
||||
|
||||
# Configure Docker for Harbor registry
|
||||
echo '{"insecure-registries": ["${{ secrets.CI_HOST }}:5000"]}' | sudo tee /etc/docker/daemon.json
|
||||
sudo systemctl restart docker
|
||||
|
||||
# Wait for Docker to be ready
|
||||
timeout 30 bash -c 'until docker info; do sleep 1; done'
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
|
@ -78,18 +90,31 @@ jobs:
|
|||
env:
|
||||
DATABASE_URL: postgres://postgres:postgres@localhost:5432/${{ secrets.APP_NAME || 'sharenet' }}_test
|
||||
run: |
|
||||
cargo test --all
|
||||
# Run tests with increased parallelism for Rust
|
||||
cargo test --all --jobs 4
|
||||
cargo clippy --all -- -D warnings
|
||||
cargo fmt --all -- --check
|
||||
|
||||
test-frontend:
|
||||
name: Test Frontend
|
||||
runs-on: ubuntu-latest
|
||||
name: Test Frontend (DinD)
|
||||
runs-on: [self-hosted, dind]
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup DinD environment
|
||||
run: |
|
||||
# Ensure DinD is running and accessible
|
||||
docker version
|
||||
|
||||
# Configure Docker for Harbor registry
|
||||
echo '{"insecure-registries": ["${{ secrets.CI_HOST }}:5000"]}' | sudo tee /etc/docker/daemon.json
|
||||
sudo systemctl restart docker
|
||||
|
||||
# Wait for Docker to be ready
|
||||
timeout 30 bash -c 'until docker info; do sleep 1; done'
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
|
@ -109,23 +134,30 @@ jobs:
|
|||
npm run build
|
||||
|
||||
build-and-push:
|
||||
name: Build and Push Docker Images
|
||||
name: Build and Push Docker Images (DinD)
|
||||
needs: [test-backend, test-frontend]
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: [self-hosted, dind]
|
||||
if: github.ref == 'refs/heads/main'
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Configure Docker for local registry
|
||||
- name: Setup DinD environment
|
||||
run: |
|
||||
# Ensure DinD is running and accessible
|
||||
docker version
|
||||
|
||||
# Configure Docker for Harbor registry
|
||||
echo '{"insecure-registries": ["${{ secrets.CI_HOST }}:5000"]}' | sudo tee /etc/docker/daemon.json
|
||||
sudo systemctl restart docker
|
||||
|
||||
# Wait for Docker to be ready
|
||||
timeout 30 bash -c 'until docker info; do sleep 1; done'
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build and push backend image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
|
@ -135,6 +167,7 @@ jobs:
|
|||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/backend:${{ github.sha }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
platforms: linux/amd64
|
||||
|
||||
- name: Build and push frontend image
|
||||
uses: docker/build-push-action@v5
|
||||
|
@ -145,17 +178,23 @@ jobs:
|
|||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/frontend:${{ github.sha }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
platforms: linux/amd64
|
||||
|
||||
deploy:
|
||||
name: Deploy to Production
|
||||
needs: build-and-push
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: [self-hosted, dind]
|
||||
if: github.ref == 'refs/heads/main'
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup DinD environment
|
||||
run: |
|
||||
# Ensure DinD is running and accessible
|
||||
docker version
|
||||
|
||||
- name: Install SQLx CLI
|
||||
run: cargo install sqlx-cli --no-default-features --features postgres
|
||||
|
||||
|
@ -195,5 +234,5 @@ jobs:
|
|||
exit 1
|
||||
}
|
||||
|
||||
# Run deployment using the new deployment script
|
||||
# Run deployment using the deployment script
|
||||
./scripts/deploy.sh deploy
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue