- Remove Containerfile and .containerignore (Apple container specific) - Update package.json to remove Apple container scripts - Replace macOS-specific build scripts with Docker-focused versions - Update README to prioritize Docker over Apple container - Update DEVELOPMENT.md to remove macOS-first approach - Update demo script to remove Apple container references - Update workflow to remove Containerfile path triggers - Simplify project to be Docker-first for cross-platform compatibility
114 lines
2.7 KiB
YAML
114 lines
2.7 KiB
YAML
name: Build Container
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
paths:
|
|
- 'src/**'
|
|
- 'public/**'
|
|
- 'package*.json'
|
|
- 'Dockerfile'
|
|
pull_request:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'src/**'
|
|
- 'public/**'
|
|
- 'package*.json'
|
|
- 'Dockerfile'
|
|
|
|
env:
|
|
IMAGE_NAME: jmespath-playground
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js 24 LTS
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run tests
|
|
run: npm test -- --coverage --watchAll=false
|
|
|
|
- name: Build React application
|
|
run: npm run build
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build container image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: false
|
|
load: true
|
|
tags: ${{ env.IMAGE_NAME }}:latest
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Test container
|
|
run: |
|
|
# Start the container
|
|
docker run --rm -d -p 3000:3000 --name test-container ${{ env.IMAGE_NAME }}:latest
|
|
|
|
# Wait for container to be ready
|
|
echo "Waiting for container to start..."
|
|
for i in {1..30}; do
|
|
if curl -f http://localhost:3000 > /dev/null 2>&1; then
|
|
echo "Container is responding!"
|
|
break
|
|
fi
|
|
if [ $i -eq 30 ]; then
|
|
echo "Container failed to respond within 30 seconds"
|
|
docker logs test-container
|
|
docker stop test-container
|
|
exit 1
|
|
fi
|
|
echo "Attempt $i/30 - waiting..."
|
|
sleep 2
|
|
done
|
|
|
|
# Test successful, stop container
|
|
docker stop test-container
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4
|
|
if: success()
|
|
with:
|
|
name: build-output
|
|
path: build/
|
|
retention-days: 7
|
|
|
|
# Optional: Build with multi-platform support for production
|
|
build-multiplatform:
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/main'
|
|
needs: build
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build multi-platform image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: false
|
|
tags: ${{ env.IMAGE_NAME }}:latest
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max |