Skip to content

Commit

Permalink
feat: add install with docker compose support (#689)
Browse files Browse the repository at this point in the history
Co-authored-by: Wendong-Fan <[email protected]>
Co-authored-by: Isaac Jin <[email protected]>
Co-authored-by: Wendong <[email protected]>
  • Loading branch information
4 people authored Jul 6, 2024
1 parent 67bcfa4 commit e3d6405
Show file tree
Hide file tree
Showing 7 changed files with 433 additions and 148 deletions.
18 changes: 18 additions & 0 deletions .container/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Necessary Keys
OPENAI_API_KEY=sk-123456789

# Optional Keys
# For Jina URL Reader
JINA_API_KEY=jina_123456789

# For Cohere Rerank
COHERE_API_KEY=abcdefghi

# For Google Search API
# https://developers.google.com/custom-search/v1/overview
GOOGLE_API_KEY=123456789
# https://cse.google.com/cse/all
SEARCH_ENGINE_ID=123456789

# For OpenWeatherMap API
OPENWEATHERMAP_API_KEY=123456789
16 changes: 16 additions & 0 deletions .container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.10-bullseye

# Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 - && \
ln -s /root/.local/bin/poetry /usr/local/bin/poetry

# Configurate Poetry
RUN poetry config virtualenvs.create false

COPY . /app/camel

WORKDIR /app/camel

RUN poetry install --with dev,docs -E all

RUN pre-commit install
89 changes: 89 additions & 0 deletions .container/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Install CAMEL with Docker

Docker offers an easy way to create a consistent and isolated virtual
environment, containers, for setting up the dependencies of CAMEL. This guide
will show you how to quickly set up CAMEL, run the examples, and also
develop on it, with Docker.

## Prerequisites
- Docker:https://docs.docker.com/engine/install/
- Docker Compose:https://docs.docker.com/compose/install/

## Cnfigure Environment
Before starting the container, you need to navigate into the
[.container](../.container) folder and create a `.env` file **with your own
API
keys**, so that these keys will be present in the environment variables of
the container, which will later be used by CAMEL. The list of API keys that
can be found in the `.env.example` file.

```bash
cd .container

# YOU SHOULD EDIT .env FILE TO ADD YOUR OWN API KEYS AFTER THIS
cp .env.example .env
```

## Start Container
After configuring the API keys, simply run the following command to start
up the working container. This will automatically set up the environment and
dependencies for CAMEL. It may take some time, please be patient.

```bash
docker compose up -d
```

After the build is completed, you can see the image `camel:latest` in the list
of images, along with a started container, `camel`.

```bash
# check the list of images
docker images

# check the list of running containers
docker ps
```

## Enter Container
You can enter the container with the following command.

```bash
docker compose exec camel bash
```

Then you will be in the container environment under the CAMEL directory, with
all the dependencies installed.

Then You can try running the
[role_playing.py](../examples/ai_society/role_playing.py)
example.

```bash
python examples/ai_society/role_playing.py
```

If you see the agents interacting with each other, this means you are all set.
Have fun with CAMEL in Docker!

## Save Your Progress
We don't support volume mounting in the Docker container currently (you are
welcomed to do this though), which means that **if you delete the
container, all the local changes you made will be LOST**. To save your
progress, committing and pushing your changes to a remote repository is a
must before deleting the container, and this is also recommended each time
before you exit the container.

## Exit, Stop and Delete the Container
You can simply press `Ctrl + D` or use the `exit` command to exit the
container.

After exiting the container, under normal cases the container will still be
running in the background. If you don't need the container anymore, you can
stop and delete the container with the following command.

```bash
docker compose down
```

As mentioned in the previous section, all the local changes you made will be
lost after deleting the container. So remember to save your progress!
10 changes: 10 additions & 0 deletions .container/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
camel:
image: camel:latest
container_name: camel
build:
context: ../
dockerfile: .container/Dockerfile
env_file:
- .env
command: ["tail", "-f", "/dev/null"]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ pip install -e .
pip install -e .[all] # (Optional)
```

### From Docker

Detailed guidance can be find [here](https://github.com/camel-ai/camel/blob/master/camel/.container/README.md)

## Documentation

[CAMEL package documentation pages](https://camel-ai.github.io/camel/).
Expand Down
Loading

0 comments on commit e3d6405

Please sign in to comment.