|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Prompt the user to enter their Docker username |
| 4 | +read -p "Enter your Docker username: " DOCKER_USERNAME |
| 5 | + |
| 6 | +# Check if the Docker username is empty |
| 7 | +if [ -z "$DOCKER_USERNAME" ]; then |
| 8 | + echo "Docker username cannot be empty." |
| 9 | + exit 1 |
| 10 | +fi |
| 11 | + |
| 12 | +# Ask if the user has an IPFS hash for their image |
| 13 | +read -p "Do you have an IPFS hash for your image? (y/n): " HAS_IPFS_HASH |
| 14 | + |
| 15 | +if [ "$HAS_IPFS_HASH" != "y" ]; then |
| 16 | + echo "Please visit the following link to learn more about how to register and mint your agent to generate an IPFS hash for your image:" |
| 17 | + echo "https://github.com/valory-xyz/olas-sdk-starter/blob/main/README.md" |
| 18 | + echo "Once you are ready with your hash, you can come back and build again." |
| 19 | + exit 0 |
| 20 | +fi |
| 21 | + |
| 22 | +# Prompt the user to enter their IPFS hash |
| 23 | +read -p "Enter your IPFS hash: " IPFS_HASH |
| 24 | + |
| 25 | +# Check if the IPFS hash is empty |
| 26 | +if [ -z "$IPFS_HASH" ]; then |
| 27 | + echo "IPFS hash cannot be empty." |
| 28 | + exit 1 |
| 29 | +fi |
| 30 | + |
| 31 | +# Navigate to the directory containing the Dockerfile |
| 32 | +cd "$(dirname "$0")/.." |
| 33 | + |
| 34 | +# Build the Docker image |
| 35 | +docker buildx build --platform=linux/amd64 -t ${DOCKER_USERNAME}/oar-memeooorr_eliza:${IPFS_HASH} . |
| 36 | + |
| 37 | +# Check if the build was successful |
| 38 | +if [ $? -eq 0 ]; then |
| 39 | + echo "Docker image built successfully." |
| 40 | + echo "Image Name: ${DOCKER_USERNAME}/oar-memeooorr_eliza:${IPFS_HASH}" |
| 41 | + # Ask if user will push the image to Docker Hub |
| 42 | + read -p "Would you like to push the image to Docker Hub? (y/n): " PUSH_IMAGE |
| 43 | + if [ "$PUSH_IMAGE" == "y" ]; then |
| 44 | + docker push ${DOCKER_USERNAME}/oar-memeooorr_eliza:${IPFS_HASH} |
| 45 | + echo "Image pushed to Docker Hub." |
| 46 | + fi |
| 47 | +else |
| 48 | + echo "Docker image build failed." |
| 49 | + exit 1 |
| 50 | +fi |
0 commit comments