Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: setup basic build #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'main' into feat/working-branch
  • Loading branch information
swizzmagik committed Nov 30, 2024
commit b6415a3747aca2e8c2c9c7f041b0b3f803d03bd3
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
node_modules
npm-debug.log
yarn-debug.log
yarn-error.log
.git
.gitignore
.env
.env.*
dist
coverage
.vscode
.idea
*.md
tests
__tests__
test
docs
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node-linker=hoisted
enable-pre-post-scripts=true
auto-install-peers=true
strict-peer-dependencies=false
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.10
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@
"build": "tsup --format esm --dts",
"start": "tsc && node --loader ts-node/esm src/index.ts",
"start:service:all": "pm2 start pnpm --name=\"all\" --restart-delay=3000 --max-restarts=10 -- run start:all",
"stop:service:all": "pm2 stop all"
"stop:service:all": "pm2 stop all",
"prepare": "node -e \"try { require('husky').install() } catch (e) {if (e.code !== 'MODULE_NOT_FOUND') throw e}\"",
"clean": "bash ./scripts/clean.sh",
"docker:build": "bash ./scripts/docker.sh build",
"docker:run": "bash ./scripts/docker.sh run",
"docker:bash": "bash ./scripts/docker.sh bash",
"docker:start": "bash ./scripts/docker.sh start",
"install": "pnpm install --include=optional sharp && node-pre-gyp rebuild",
"postinstall": "node-pre-gyp install --fallback-to-build",
"docker": "pnpm docker:build && pnpm docker:run && pnpm docker:bash"
},
"dependencies": {
"@ai16z/adapter-postgres": "latest",
Expand All @@ -31,14 +40,9 @@
"engines": {
"node": ">=22"
},
"pnpm": {
"overrides": {
"onnxruntime-node": "^1.20.0"
}
},
"devDependencies": {
"ts-node": "10.9.2",
"tsup": "^8.3.5",
"typescript": "^5.6.3"
}
}
}
11 changes: 11 additions & 0 deletions scripts/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Navigate to the script's directory
cd "$(dirname "$0")"/..
echo "Cleanup started."
# Find and remove node_modules directories, dist directories, and pnpm-lock.yaml files
find . -type d -name "node_modules" -exec rm -rf {} + \
-o -type d -name "dist" -exec rm -rf {} + \
-o -type f -name "pnpm-lock.yaml" -exec rm -f {} +

echo "Cleanup completed."
90 changes: 90 additions & 0 deletions scripts/docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/bash

# Check if an argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 {build|run|start|bash}"
exit 1
fi

# Execute the corresponding command based on the argument
case "$1" in
build)
docker build --platform linux/amd64 -t eliza .
;;
run)
# Ensure the container is not already running
if [ "$(docker ps -q -f name=eliza)" ]; then
echo "Container 'eliza' is already running. Stopping it first."
docker stop eliza
docker rm eliza
fi

# Define base directories to mount
BASE_MOUNTS=(
"characters:/app/characters"
".env:/app/.env"
"agent:/app/agent"
"docs:/app/docs"
"scripts:/app/scripts"
)

# Define package directories to mount
PACKAGES=(
"adapter-postgres"
"adapter-sqlite"
"adapter-sqljs"
"adapter-supabase"
"client-auto"
"client-direct"
"client-discord"
"client-telegram"
"client-twitter"
"core"
"plugin-bootstrap"
"plugin-image-generation"
"plugin-node"
"plugin-solana"
"plugin-evm"
"plugin-tee"
)

# Start building the docker run command
CMD="docker run --platform linux/amd64 -p 3000:3000 -d"

# Add base mounts
for mount in "${BASE_MOUNTS[@]}"; do
CMD="$CMD -v \"$(pwd)/$mount\""
done

# Add package mounts
for package in "${PACKAGES[@]}"; do
CMD="$CMD -v \"$(pwd)/packages/$package/src:/app/packages/$package/src\""
done

# Add core types mount separately (special case)
CMD="$CMD -v \"$(pwd)/packages/core/types:/app/packages/core/types\""

# Add container name and image
CMD="$CMD --name eliza eliza"

# Execute the command
eval $CMD
;;
start)
docker start eliza
;;
bash)
# Check if the container is running before executing bash
if [ "$(docker ps -q -f name=eliza)" ]; then
docker exec -it eliza bash
else
echo "Container 'eliza' is not running. Please start it first."
exit 1
fi
;;
*)
echo "Invalid option: $1"
echo "Usage: $0 {build|run|start|bash}"
exit 1
;;
esac
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.