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:
|
on:
|
||||||
push:
|
push:
|
||||||
|
@ -12,8 +12,8 @@ env:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-backend:
|
test-backend:
|
||||||
name: Test Backend
|
name: Test Backend (DinD)
|
||||||
runs-on: ubuntu-latest
|
runs-on: [self-hosted, dind]
|
||||||
|
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
|
@ -33,6 +33,18 @@ jobs:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
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
|
- name: Install Rust toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
|
@ -78,18 +90,31 @@ jobs:
|
||||||
env:
|
env:
|
||||||
DATABASE_URL: postgres://postgres:postgres@localhost:5432/${{ secrets.APP_NAME || 'sharenet' }}_test
|
DATABASE_URL: postgres://postgres:postgres@localhost:5432/${{ secrets.APP_NAME || 'sharenet' }}_test
|
||||||
run: |
|
run: |
|
||||||
cargo test --all
|
# Run tests with increased parallelism for Rust
|
||||||
|
cargo test --all --jobs 4
|
||||||
cargo clippy --all -- -D warnings
|
cargo clippy --all -- -D warnings
|
||||||
cargo fmt --all -- --check
|
cargo fmt --all -- --check
|
||||||
|
|
||||||
test-frontend:
|
test-frontend:
|
||||||
name: Test Frontend
|
name: Test Frontend (DinD)
|
||||||
runs-on: ubuntu-latest
|
runs-on: [self-hosted, dind]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
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
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
|
@ -109,22 +134,29 @@ jobs:
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
build-and-push:
|
build-and-push:
|
||||||
name: Build and Push Docker Images
|
name: Build and Push Docker Images (DinD)
|
||||||
needs: [test-backend, test-frontend]
|
needs: [test-backend, test-frontend]
|
||||||
runs-on: ubuntu-latest
|
runs-on: [self-hosted, dind]
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Setup DinD environment
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Configure Docker for local registry
|
|
||||||
run: |
|
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
|
echo '{"insecure-registries": ["${{ secrets.CI_HOST }}:5000"]}' | sudo tee /etc/docker/daemon.json
|
||||||
sudo systemctl restart docker
|
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
|
- name: Build and push backend image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
|
@ -135,6 +167,7 @@ jobs:
|
||||||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/backend:${{ github.sha }}
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/backend:${{ github.sha }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
||||||
- name: Build and push frontend image
|
- name: Build and push frontend image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
|
@ -145,17 +178,23 @@ jobs:
|
||||||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/frontend:${{ github.sha }}
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/frontend:${{ github.sha }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy to Production
|
name: Deploy to Production
|
||||||
needs: build-and-push
|
needs: build-and-push
|
||||||
runs-on: ubuntu-latest
|
runs-on: [self-hosted, dind]
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup DinD environment
|
||||||
|
run: |
|
||||||
|
# Ensure DinD is running and accessible
|
||||||
|
docker version
|
||||||
|
|
||||||
- name: Install SQLx CLI
|
- name: Install SQLx CLI
|
||||||
run: cargo install sqlx-cli --no-default-features --features postgres
|
run: cargo install sqlx-cli --no-default-features --features postgres
|
||||||
|
|
||||||
|
@ -195,5 +234,5 @@ jobs:
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run deployment using the new deployment script
|
# Run deployment using the deployment script
|
||||||
./scripts/deploy.sh deploy
|
./scripts/deploy.sh deploy
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue