- Remove container specification from docker-build job - Use 'runs-on: docker' without container to access Docker directly - This might allow direct access to host Docker daemon - Test if Buildx can work without network isolation issues
143 lines
4.3 KiB
YAML
143 lines
4.3 KiB
YAML
name: Lint, Build, and Docker
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main, develop]
|
|
|
|
jobs:
|
|
# ==============================================================================
|
|
# Job 1: Format Check
|
|
# ==============================================================================
|
|
format:
|
|
runs-on: docker
|
|
container:
|
|
image: rust:latest
|
|
|
|
steps:
|
|
- name: Install Node.js for checkout
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y curl gnupg
|
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
|
apt-get install -y nodejs
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y pkg-config libssl-dev
|
|
rustup component add rustfmt
|
|
|
|
- name: Check formatting
|
|
working-directory: ./backend
|
|
run: cargo fmt --all -- --check
|
|
|
|
# ==============================================================================
|
|
# Job 2: Lint
|
|
# ==============================================================================
|
|
clippy:
|
|
runs-on: docker
|
|
container:
|
|
image: rust:latest
|
|
|
|
steps:
|
|
- name: Install Node.js for checkout
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y curl gnupg
|
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
|
apt-get install -y nodejs
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y pkg-config libssl-dev
|
|
rustup component add clippy
|
|
|
|
- name: Run Clippy
|
|
working-directory: ./backend
|
|
run: cargo clippy --all-targets --all-features
|
|
|
|
# ==============================================================================
|
|
# Job 3: Build - Depends on format and clippy
|
|
# ==============================================================================
|
|
build:
|
|
runs-on: docker
|
|
container:
|
|
image: rust:latest
|
|
needs: [format, clippy]
|
|
|
|
steps:
|
|
- name: Install Node.js for checkout
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y curl gnupg
|
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
|
apt-get install -y nodejs
|
|
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y pkg-config libssl-dev
|
|
|
|
- name: Build release binary
|
|
working-directory: ./backend
|
|
run: cargo build --release --verbose
|
|
|
|
# ==============================================================================
|
|
# Job 4: Docker Build with Buildx - Using runs-on: docker without container
|
|
# ==============================================================================
|
|
docker-build:
|
|
runs-on: docker
|
|
# No container - should have direct Docker access
|
|
needs: [build]
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Verify Docker is available
|
|
run: |
|
|
docker version
|
|
docker info
|
|
|
|
- name: Set up Docker Buildx
|
|
run: |
|
|
docker buildx version
|
|
docker buildx create --use --name builder
|
|
docker buildx inspect --bootstrap
|
|
|
|
- name: Build Docker image with Buildx
|
|
working-directory: ./backend
|
|
run: |
|
|
docker buildx build \
|
|
--file docker/Dockerfile \
|
|
--tag normogen-backend:${{ github.sha }} \
|
|
--tag normogen-backend:latest \
|
|
--cache-from type=local,src=/tmp/.buildx-cache \
|
|
--cache-to type=local,dest=/tmp/.buildx-cache-new,mode=max \
|
|
--load \
|
|
.
|
|
|
|
# Rotate cache
|
|
rm -rf /tmp/.buildx-cache
|
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache || true
|
|
|
|
- name: Test Docker image
|
|
run: |
|
|
docker run --rm normogen-backend:${{ github.sha }} ls -la /app/normogen-backend || echo "Binary check"
|
|
|
|
- name: Show image info
|
|
run: |
|
|
docker images normogen-backend
|
|
docker inspect normogen-backend:${{ github.sha }} || echo "Image inspect"
|