Fix GitHub Actions build issues
🔧 Fixed Build Problems: - Add proper Node.js setup with npm caching - Use working-directory for client build step - Add client build verification with error handling - Simplified workflow removing complex artifact generation - Better error messages and build status reporting 🔄 Node.js Version Handling: - Set explicit Node.js 18 setup - Removed deprecated Node.js 24 environment variable - Added proper npm cache configuration - Cache both client and server package-lock.json files ✅ Build Process: 1. Checkout repository 2. Set up Node.js 18 with npm caching 3. Build React client with npm ci + npm run build 4. Verify client build succeeded 5. Build multi-platform Docker image 6. Push to GitHub Container Registry This should resolve the npm build command not found error and Node.js deprecation warnings.
This commit is contained in:
parent
1504ae6eea
commit
b0280ae9af
1 changed files with 29 additions and 80 deletions
109
.github/workflows/docker-build.yml
vendored
109
.github/workflows/docker-build.yml
vendored
|
|
@ -22,6 +22,15 @@ jobs:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '18'
|
||||||
|
cache: 'npm'
|
||||||
|
cache-dependency-path: |
|
||||||
|
client/package-lock.json
|
||||||
|
server/package-lock.json
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
|
@ -46,11 +55,22 @@ jobs:
|
||||||
type=sha,prefix=sha-
|
type=sha,prefix=sha-
|
||||||
|
|
||||||
- name: Build React client
|
- name: Build React client
|
||||||
|
working-directory: ./client
|
||||||
run: |
|
run: |
|
||||||
cd client
|
|
||||||
npm ci
|
npm ci
|
||||||
npm run build
|
npm run build
|
||||||
cd ..
|
|
||||||
|
- name: Verify client build
|
||||||
|
run: |
|
||||||
|
ls -la client/dist/ || echo "No dist directory found"
|
||||||
|
if [ -d "client/dist" ]; then
|
||||||
|
echo "✅ Client build successful"
|
||||||
|
echo "Build contents:"
|
||||||
|
find client/dist -type f | head -5
|
||||||
|
else
|
||||||
|
echo "❌ Client build failed - no dist directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
|
|
@ -63,83 +83,12 @@ jobs:
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
- name: Generate deployment artifact
|
- name: Image build summary
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
run: |
|
run: |
|
||||||
mkdir -p deployment
|
echo "✅ Docker image built and pushed successfully!"
|
||||||
|
echo "📦 Image tags:"
|
||||||
# Create production docker-compose file
|
echo "${{ steps.meta.outputs.tags }}"
|
||||||
cat > deployment/docker-compose.prod.yml << 'EOF'
|
echo ""
|
||||||
version: '3.8'
|
echo "🚀 Deploy on your Mac Mini with:"
|
||||||
|
echo "git pull && ./build-deploy.sh ghcr"
|
||||||
services:
|
|
||||||
nginx:
|
|
||||||
image: nginx:alpine
|
|
||||||
container_name: etsy-nginx
|
|
||||||
ports:
|
|
||||||
- "3000:80"
|
|
||||||
volumes:
|
|
||||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
|
||||||
- client_dist:/usr/share/nginx/html:ro
|
|
||||||
depends_on:
|
|
||||||
- etsy-tracker
|
|
||||||
restart: unless-stopped
|
|
||||||
networks:
|
|
||||||
- etsy-network
|
|
||||||
|
|
||||||
etsy-tracker:
|
|
||||||
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
|
|
||||||
container_name: etsy-finance-tracker
|
|
||||||
expose:
|
|
||||||
- "8080"
|
|
||||||
environment:
|
|
||||||
- NODE_ENV=production
|
|
||||||
- PORT=8080
|
|
||||||
volumes:
|
|
||||||
- ./data:/app/data
|
|
||||||
- etsy_uploads:/app/uploads
|
|
||||||
- client_dist:/usr/share/nginx/html
|
|
||||||
restart: unless-stopped
|
|
||||||
networks:
|
|
||||||
- etsy-network
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
etsy_uploads:
|
|
||||||
client_dist:
|
|
||||||
|
|
||||||
networks:
|
|
||||||
etsy-network:
|
|
||||||
driver: bridge
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Copy nginx config
|
|
||||||
cp nginx.conf deployment/
|
|
||||||
|
|
||||||
# Create deployment script
|
|
||||||
cat > deployment/deploy.sh << 'EOF'
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo "🚀 Deploying Etsy Finance Tracker..."
|
|
||||||
|
|
||||||
# Pull latest image
|
|
||||||
docker-compose -f docker-compose.prod.yml pull
|
|
||||||
|
|
||||||
# Stop existing containers
|
|
||||||
docker-compose -f docker-compose.prod.yml down
|
|
||||||
|
|
||||||
# Start with new image
|
|
||||||
docker-compose -f docker-compose.prod.yml up -d
|
|
||||||
|
|
||||||
echo "✅ Deployment complete!"
|
|
||||||
echo "🌐 Access your app at: http://localhost:3000"
|
|
||||||
EOF
|
|
||||||
|
|
||||||
chmod +x deployment/deploy.sh
|
|
||||||
|
|
||||||
- name: Upload deployment artifacts
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: deployment-files
|
|
||||||
path: deployment/
|
|
||||||
retention-days: 30
|
|
||||||
Loading…
Reference in a new issue