@@ -144,13 +144,6 @@ jobs:
144144 - name : Checkout code
145145 uses : actions/checkout@v4
146146
147- - name : Log in to Oracle Container Registry
148- uses : docker/login-action@v2
149- with :
150- registry : ${{ secrets.OCI_REGISTRY }}
151- username : ${{ secrets.OCI_USERNAME }}
152- password : ${{ secrets.OCI_AUTH_TOKEN }}
153-
154147 - name : Deploy to Oracle VM
155148 env :
156149 ORACLE_VM_IP : ${{ secrets.ORACLE_VM_IP }}
@@ -163,74 +156,27 @@ jobs:
163156 echo "$SSH_KEY" > ssh_key.pem
164157 chmod 600 ssh_key.pem
165158
166- # Create deployment directory
167- ssh -o StrictHostKeyChecking=no -i ssh_key.pem opc@${ORACLE_VM_IP} mkdir -p ~/music-analytics/vm-deploy
159+ # Verify VM connection
160+ ssh -o StrictHostKeyChecking=no -i ssh_key.pem opc@${ORACLE_VM_IP} "echo VM connection verified"
168161
169- # Copy Docker Compose file
162+ # Create directory and copy docker-compose file
163+ ssh -o StrictHostKeyChecking=no -i ssh_key.pem opc@${ORACLE_VM_IP} "mkdir -p ~/music-analytics/vm-deploy"
170164 scp -o StrictHostKeyChecking=no -i ssh_key.pem cloud-deploy/docker-compose.direct.yml opc@${ORACLE_VM_IP}:~/music-analytics/vm-deploy/docker-compose.yml
171165
172- # Create deployment script with environment variables
173- cat << EOF > deploy.sh
174- #!/bin/bash
175- cd ~/music-analytics/vm-deploy
176-
177- # Set environment variables
178- export DOCKER_REGISTRY=${DOCKER_REGISTRY}
179- export ORACLE_EXTERNAL_HOSTNAME=music-analytics.abenezeranglo.uk
180- export EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://eureka-server:8761/eureka/
181-
182- # Stop and clean up existing containers
183- docker-compose down --remove-orphans || true
184- docker container prune -f || true
185- docker image prune -f || true
186-
187- # Pull and start services
188- docker-compose pull
189- docker-compose up -d eureka-server
190-
191- # Wait for Eureka server to be healthy
192- echo "Waiting for Eureka server to be healthy..."
193- for i in \$(seq 1 60); do
194- if docker-compose ps eureka-server | grep -q "healthy"; then
195- echo "Eureka server is healthy"
196- break
197- fi
198- if [ \$i -eq 60 ]; then
199- echo "Timeout waiting for Eureka server to be healthy"
200- docker-compose logs eureka-server
201- exit 1
202- fi
203- echo "Waiting... (\$i/60)"
204- sleep 5
205- done
206-
207- # Start other services
208- docker-compose up -d api-gateway recommendation-service statistics-service user-tracking-service
209-
210- # Show status of all services
211- echo "Service status:"
212- docker-compose ps
213-
214- # Show logs if any service is unhealthy
215- if docker-compose ps | grep -q "unhealthy\|Exit"; then
216- echo "Some services are unhealthy or exited. Showing logs:"
217- docker-compose logs
218- exit 1
219- fi
220-
221- echo "Deployment completed successfully"
222- EOF
223-
224- # Copy and execute deployment script
225- scp -o StrictHostKeyChecking=no -i ssh_key.pem deploy.sh opc@${ORACLE_VM_IP}:~/music-analytics/vm-deploy/
166+ # Execute deployment commands directly
226167 ssh -o StrictHostKeyChecking=no -i ssh_key.pem opc@${ORACLE_VM_IP} "cd ~/music-analytics/vm-deploy && \
227- chmod +x deploy.sh && \
228168 docker login ${DOCKER_REGISTRY} -u ${OCI_USERNAME} -p ${OCI_AUTH_TOKEN} && \
229- ./deploy.sh && \
169+ export ORACLE_EXTERNAL_HOSTNAME=music-analytics.abenezeranglo.uk && \
170+ export EUREKA_CLIENT_SERVICEURL_DEFAULTZONE=http://eureka-server:8761/eureka/ && \
171+ export DOCKER_REGISTRY=${DOCKER_REGISTRY} && \
172+ docker-compose down --remove-orphans || true && \
173+ docker-compose pull && \
174+ docker-compose up -d && \
175+ docker-compose ps && \
230176 docker logout ${DOCKER_REGISTRY}"
231177
232178 # Clean up
233- rm -f ssh_key.pem deploy.sh
179+ rm -f ssh_key.pem
234180
235181 - name : Log out from Oracle Container Registry
236182 if : always()
0 commit comments