-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-oracle-cloud.sh
More file actions
61 lines (50 loc) · 1.74 KB
/
deploy-oracle-cloud.sh
File metadata and controls
61 lines (50 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Oracle Cloud Deployment Script
# This script builds and deploys the application to Oracle Cloud
echo "🚀 Starting Oracle Cloud Deployment..."
# Configuration
APP_NAME="ers-springboot"
DOCKER_REGISTRY="<your-region>.ocir.io"
DOCKER_NAMESPACE="<your-tenancy-namespace>"
IMAGE_TAG="${DOCKER_REGISTRY}/${DOCKER_NAMESPACE}/${APP_NAME}:latest"
# Step 1: Build the Docker image
echo "📦 Building Docker image..."
docker build -t ${APP_NAME}:latest .
if [ $? -ne 0 ]; then
echo "❌ Docker build failed!"
exit 1
fi
echo "✅ Docker image built successfully!"
# Step 2: Tag the image for Oracle Container Registry
echo "🏷️ Tagging image for Oracle Container Registry..."
docker tag ${APP_NAME}:latest ${IMAGE_TAG}
# Step 3: Push to Oracle Container Registry
echo "📤 Pushing image to Oracle Container Registry..."
echo "Please make sure you're logged in to OCIR:"
echo "docker login ${DOCKER_REGISTRY}"
echo ""
read -p "Press Enter to continue with push..."
docker push ${IMAGE_TAG}
if [ $? -ne 0 ]; then
echo "❌ Failed to push image to OCIR!"
echo "Make sure you're logged in: docker login ${DOCKER_REGISTRY}"
exit 1
fi
echo "✅ Image pushed successfully!"
echo ""
echo "🎉 Deployment preparation complete!"
echo ""
echo "Next steps:"
echo "1. Create a Compute instance in Oracle Cloud"
echo "2. SSH into the instance"
echo "3. Install Docker on the instance"
echo "4. Pull the image: docker pull ${IMAGE_TAG}"
echo "5. Run the container with environment variables"
echo ""
echo "Sample run command:"
echo "docker run -d -p 8080:8080 \\"
echo " -e DATABASE_URL=<your-db-url> \\"
echo " -e DATABASE_USERNAME=<your-db-user> \\"
echo " -e DATABASE_PASSWORD=<your-db-password> \\"
echo " --name ers-app \\"
echo " ${IMAGE_TAG}"