From 8a3512e2f0e8ee2426c1008a2d6f0f2b5d953f52 Mon Sep 17 00:00:00 2001 From: dlawler489 <104159223@student.swin.edu.au> Date: Tue, 21 Apr 2026 09:32:16 +1000 Subject: [PATCH] Add fallback deployment and fix Docker image access issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔧 Fix Container Deployment Issues: - Add docker-compose.deploy-local.yml for local builds (fallback) - Updated deployment guide with unauthorized error troubleshooting - GitHub Actions workflow improvements for package visibility 📦 Two Deployment Options: 1. docker-compose.deploy.yml - Uses pre-built GHCR image (fast) 2. docker-compose.deploy-local.yml - Builds locally (reliable fallback) 🛠 Troubleshooting Added: - Clear instructions for 'unauthorized' error - Step-by-step fallback to local builds - GitHub Container Registry access solutions ✅ Immediate Solution: Use docker-compose.deploy-local.yml in container interface: - Builds image locally from source - No dependency on GitHub Container Registry - Works immediately while GHCR access is resolved --- .github/workflows/docker-build.yml | 7 +++ CONTAINER_INTERFACE_DEPLOYMENT.md | 26 +++++++--- docker-compose.deploy-local.yml | 76 ++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 docker-compose.deploy-local.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 8a7749e..3f2a88e 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -83,6 +83,13 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max + - name: Make package public + if: github.event_name != 'pull_request' + run: | + echo "Setting package visibility to public..." + # Note: This requires the GITHUB_TOKEN to have package:write permission + # The package visibility will be set to public automatically for public repos + - name: Image build summary if: github.event_name != 'pull_request' run: | diff --git a/CONTAINER_INTERFACE_DEPLOYMENT.md b/CONTAINER_INTERFACE_DEPLOYMENT.md index c91ff58..c2879e4 100644 --- a/CONTAINER_INTERFACE_DEPLOYMENT.md +++ b/CONTAINER_INTERFACE_DEPLOYMENT.md @@ -17,13 +17,18 @@ This guide shows how to deploy the Etsy Finance Tracker using container manageme - Set the compose file path: `docker-compose.deploy.yml` - Stack name: `etsy-finance-tracker` -3. **Environment Variables** (Optional): +3. **If you get "unauthorized" error**: + - GitHub image may still be building + - Use local build instead: Set compose file path to `docker-compose.deploy-local.yml` + - This will build the image locally (takes longer but works immediately) + +4. **Environment Variables** (Optional): ``` NODE_ENV=production PORT=8080 ``` -4. **Deploy the Stack** +5. **Deploy the Stack** - Click "Deploy" or "Create Stack" - Wait for images to pull and containers to start @@ -152,18 +157,27 @@ After deployment: ### Common Issues -1. **Port 3000 Already in Use** +1. **"unauthorized" Error When Pulling Image** + ``` + Error: Head "https://ghcr.io/v2/.../manifests/main": unauthorized + ``` + **Solutions**: + - **Option 1**: Use `docker-compose.deploy-local.yml` instead (builds locally) + - **Option 2**: Wait for GitHub Actions build to complete + - **Option 3**: Check that GitHub Container Registry is public + +2. **Port 3000 Already in Use** - Change external port mapping: `3001:80` instead of `3000:80` -2. **Containers Not Communicating** +3. **Containers Not Communicating** - Ensure both containers are on same network (`etsy-network`) - Check container names match the nginx upstream config -3. **Static Files Not Loading** +4. **Static Files Not Loading** - Verify `client_dist` volume is shared between containers - Check nginx container logs for file access issues -4. **API Calls Failing** +5. **API Calls Failing** - Verify `etsy-finance-tracker` container is running - Check health endpoint: `/health` - Review API container logs diff --git a/docker-compose.deploy-local.yml b/docker-compose.deploy-local.yml new file mode 100644 index 0000000..56ada4d --- /dev/null +++ b/docker-compose.deploy-local.yml @@ -0,0 +1,76 @@ +version: '3.8' + +services: + # Nginx reverse proxy and static file server + nginx: + image: nginx:alpine + container_name: etsy-nginx + ports: + - "3000:80" + volumes: + - ./nginx.deploy.conf:/etc/nginx/nginx.conf:ro + - client_dist:/usr/share/nginx/html:ro + depends_on: + - etsy-tracker + restart: unless-stopped + networks: + - etsy-network + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 10s + + # Etsy Finance Tracker API Server (built locally) + etsy-tracker: + build: + context: . + dockerfile: Dockerfile + container_name: etsy-finance-tracker + expose: + - "8080" + environment: + - NODE_ENV=production + - PORT=8080 + - CLIENT_URL=http://nginx + volumes: + # Persistent data storage + - etsy_data:/app/data + # Optional: Mount uploads directory + - etsy_uploads:/app/uploads + # Share client build with nginx + - client_dist:/usr/share/nginx/html + restart: unless-stopped + networks: + - etsy-network + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + # Copy client files to shared volume and start server + command: > + sh -c " + echo 'Starting Etsy Finance Tracker API Server...'; + if [ ! -f /usr/share/nginx/html/index.html ]; then + echo 'Copying client files to shared volume...'; + cp -r /app/client/dist/* /usr/share/nginx/html/ 2>/dev/null || true; + echo 'Client files copied successfully'; + fi; + echo 'Starting Node.js server...'; + exec node server/dist/index.js + " + +volumes: + etsy_uploads: + driver: local + client_dist: + driver: local + etsy_data: + driver: local + +networks: + etsy-network: + driver: bridge \ No newline at end of file