Skip to content

Commit 54aeb20

Browse files
committed
feat(build): functionality to build and push agent
1 parent af85334 commit 54aeb20

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

docs/agents.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@
2525
git submodule update --init --recursive
2626
```
2727
28-
2. Create the virtual environment:
28+
2. Install dependencies:
2929
3030
```
3131
cd agents-fun-eliza
3232
pnpm install
3333
```
3434
35-
3. Build the packages:
35+
3. Define your character description in agents-fun/characters/eliza.character.json and update the system, bio and lore section as per your liking.
36+
37+
4. Build and push the agent to your docker hub :
3638
```
37-
pnpm build
39+
pnpm build:agent
3840
```
3941
4042
#### Prepare the data

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"author": "",
66
"scripts": {
77
"build": "lerna run build --stream",
8+
"build:agent": "./scripts/build.sh",
89
"start": "pnpm --filter \"agents-fun\" start --isRoot",
910
"start:with-args": "tsc && node --loader ts-node/esm src/index.ts --",
1011
"clean": "lerna clean",

scripts/build.sh

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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

Comments
 (0)