Skip to content

Commit ad6f439

Browse files
committed
Dockerized application for local development, testing and deployment
1 parent 7fcf54e commit ad6f439

File tree

6 files changed

+112
-1
lines changed

6 files changed

+112
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules
22
/out
33

44
.env
5+
.env.production
56
concatenated-output.ts
67
embedding-cache.json
78

Dockerfile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM node:23.1.0
2+
# Install pnpm globally
3+
RUN npm install -g pnpm@9.4.0
4+
5+
# Set the working directory
6+
WORKDIR /app
7+
8+
# Add configuration files and install dependencies
9+
ADD pnpm-workspace.yaml /app/pnpm-workspace.yaml
10+
ADD package.json /app/package.json
11+
ADD .npmrc /app/.npmrc
12+
ADD tsconfig.json /app/tsconfig.json
13+
ADD pnpm-lock.yaml /app/pnpm-lock.yaml
14+
RUN pnpm i
15+
16+
# Add the documentation
17+
ADD docs /app/docs
18+
RUN pnpm i
19+
20+
# Add the rest of the application code
21+
ADD packages /app/packages
22+
RUN pnpm i
23+
24+
# Add the environment variables
25+
ADD scripts /app/scripts
26+
ADD characters /app/characters
27+
ADD .env /app/.env
28+
29+
# Command to run the container
30+
CMD ["tail", "-f", "/dev/null"]

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,11 @@ Tests are written using Jest and can be found in `src/**/*.test.ts` files. The t
178178
- Run tests in sequence (--runInBand)
179179

180180
To create new tests, add a `.test.ts` file adjacent to the code you're testing.
181+
182+
## Docker
183+
184+
For development purposes, you can run the docker container with the following command:
185+
186+
```
187+
pnpm docker
188+
```

package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
"lint": "pnpm --dir packages/core lint && pnpm --dir packages/agent lint",
1313
"prettier-check": "npx prettier --check .",
1414
"prettier": "npx prettier --write .",
15-
"clean": "bash ./scripts/clean.sh"
15+
"clean": "bash ./scripts/clean.sh",
16+
"docker:build": "bash ./scripts/docker.sh build",
17+
"docker:run": "bash ./scripts/docker.sh run",
18+
"docker:bash": "bash ./scripts/docker.sh bash",
19+
"docker:start": "bash ./scripts/docker.sh start",
20+
"docker": "pnpm docker:build && pnpm docker:run && pnpm docker:bash"
1621
},
1722
"devDependencies": {
1823
"concurrently": "^9.1.0",

packages/client-direct/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@types/express": "5.0.0",
1313
"body-parser": "1.20.3",
1414
"cors": "2.8.5",
15+
"express": "^4.21.1",
1516
"multer": "1.4.5-lts.1"
1617
},
1718
"devDependencies": {

scripts/docker.sh

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
# Check if an argument is provided
4+
if [ -z "$1" ]; then
5+
echo "Usage: $0 {build|run|start|bash}"
6+
exit 1
7+
fi
8+
9+
# Execute the corresponding command based on the argument
10+
case "$1" in
11+
build)
12+
docker build --platform linux/amd64 -t eliza .
13+
;;
14+
run)
15+
# Ensure the container is not already running
16+
if [ "$(docker ps -q -f name=eliza)" ]; then
17+
echo "Container 'eliza' is already running. Stopping it first."
18+
docker stop eliza
19+
docker rm eliza
20+
fi
21+
22+
docker run \
23+
--platform linux/amd64 \
24+
-p 3000:3000 \
25+
-d \
26+
-v "$(pwd)/characters:/app/characters" \
27+
-v "$(pwd)/.env:/app/.env" \
28+
-v "$(pwd)/docs:/app/docs" \
29+
-v "$(pwd)/scripts:/app/scripts" \
30+
-v "$(pwd)/packages/adapter-postgres/src:/app/packages/adapter-postgres/src" \
31+
-v "$(pwd)/packages/adapter-sqlite/src:/app/packages/adapter-sqlite/src" \
32+
-v "$(pwd)/packages/adapter-sqljs/src:/app/packages/adapter-sqljs/src" \
33+
-v "$(pwd)/packages/adapter-supabase/src:/app/packages/adapter-supabase/src" \
34+
-v "$(pwd)/packages/agent/src:/app/packages/agent/src" \
35+
-v "$(pwd)/packages/client-auto/src:/app/packages/client-auto/src" \
36+
-v "$(pwd)/packages/client-direct/src:/app/packages/client-direct/src" \
37+
-v "$(pwd)/packages/client-discord/src:/app/packages/client-discord/src" \
38+
-v "$(pwd)/packages/client-telegram/src:/app/packages/client-telegram/src" \
39+
-v "$(pwd)/packages/client-twitter/src:/app/packages/client-twitter/src" \
40+
-v "$(pwd)/packages/core/src:/app/packages/core/src" \
41+
-v "$(pwd)/packages/core/types:/app/packages/core/types" \
42+
-v "$(pwd)/packages/plugin-bootstrap/src:/app/packages/plugin-bootstrap/src" \
43+
-v "$(pwd)/packages/plugin-image-generation/src:/app/packages/plugin-image-generation/src" \
44+
-v "$(pwd)/packages/plugin-node/src:/app/packages/plugin-node/src" \
45+
-v "$(pwd)/packages/plugin-solana/src:/app/packages/plugin-solana/src" \
46+
--name eliza \
47+
eliza
48+
;;
49+
start)
50+
docker start eliza
51+
;;
52+
bash)
53+
# Check if the container is running before executing bash
54+
if [ "$(docker ps -q -f name=eliza)" ]; then
55+
docker exec -it eliza bash
56+
else
57+
echo "Container 'eliza' is not running. Please start it first."
58+
exit 1
59+
fi
60+
;;
61+
*)
62+
echo "Invalid option: $1"
63+
echo "Usage: $0 {build|run|start|bash}"
64+
exit 1
65+
;;
66+
esac

0 commit comments

Comments
 (0)