@@ -95,44 +95,10 @@ jobs:
9595 cache-from : type=gha
9696 cache-to : type=gha,mode=max
9797
98- build-and-push-frontend :
99- name : Build and Push Frontend Image
100- runs-on : ubuntu-latest
101- needs : [frontend-checks]
102- if : github.ref == 'refs/heads/main' && github.event_name == 'push'
103- steps :
104- - name : Checkout code
105- uses : actions/checkout@v4
106-
107- - name : Set up Docker Buildx
108- uses : docker/setup-buildx-action@v3
109-
110- - name : Login to Vultr Container Registry
111- uses : docker/login-action@v3
112- with :
113- registry : ams.vultrcr.com
114- username : ${{ secrets.VULTR_REGISTRY_USERNAME }}
115- password : ${{ secrets.VULTR_REGISTRY_PASSWORD }}
116-
117- - name : Build and push Frontend image
118- uses : docker/build-push-action@v5
119- with :
120- context : .
121- file : frontend/Dockerfile
122- push : true
123- platforms : linux/amd64
124- tags : |
125- ${{ env.REGISTRY }}/frontend:latest
126- ${{ env.REGISTRY }}/frontend:${{ github.sha }}
127- build-args : |
128- NEXT_PUBLIC_API_URL=/api
129- cache-from : type=gha
130- cache-to : type=gha,mode=max
131-
13298 deploy :
13399 name : Deploy to Vultr VPC
134100 runs-on : ubuntu-latest
135- needs : [build-and-push-api, build-and-push-frontend ]
101+ needs : [build-and-push-api]
136102 if : github.ref == 'refs/heads/main' && github.event_name == 'push'
137103 steps :
138104 - name : Checkout code
@@ -158,15 +124,16 @@ jobs:
158124 # Login to Vultr registry
159125 echo "${{ secrets.VULTR_REGISTRY_PASSWORD }}" | docker login ams.vultrcr.com -u ${{ secrets.VULTR_REGISTRY_USERNAME }} --password-stdin
160126
127+ # Cleanup old images and build cache before pulling
128+ docker image prune -af
129+ docker builder prune -af
130+
161131 # Pull latest images
162132 docker compose pull
163133
164134 # Deploy with zero-downtime
165135 docker compose up -d --remove-orphans
166136
167- # Cleanup old images
168- docker image prune -f
169-
170137 # Health check
171138 sleep 10
172139 curl -f http://localhost:8000/api/v1/health || exit 1
@@ -203,11 +170,3 @@ jobs:
203170 echo "Deleting old tag: $TAG"
204171 regctl tag delete ${{ env.REGISTRY }}/api:$TAG || true
205172 done
206-
207- - name : Cleanup old Frontend images (keep latest 2)
208- run : |
209- TAGS=$(regctl tag list ${{ env.REGISTRY }}/frontend 2>/dev/null | grep -v '^latest$' | tail -n +3) || true
210- for TAG in $TAGS; do
211- echo "Deleting old tag: $TAG"
212- regctl tag delete ${{ env.REGISTRY }}/frontend:$TAG || true
213- done
0 commit comments