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

guide on the usage of docker #1111

Merged
merged 44 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f6ced0b
docker documentation
qingyun-wu Dec 31, 2023
fe4ed59
docker doc
qingyun-wu Dec 31, 2023
b043ca4
Merge branch 'main' into add-docker
qingyun-wu Dec 31, 2023
ca9b435
clean contribute.md
qingyun-wu Dec 31, 2023
c6c247b
Merge branch 'add-docker' of https://github.com/microsoft/autogen int…
qingyun-wu Dec 31, 2023
47e19c8
Merge branch 'add-docker' of https://github.com/microsoft/autogen int…
qingyun-wu Dec 31, 2023
4c7f879
Merge branch 'add-docker' of https://github.com/microsoft/autogen int…
Jan 1, 2024
d12493e
Merge branch 'add-docker' of https://github.com/microsoft/autogen int…
Jan 1, 2024
4106a25
Merge branch 'add-docker' of https://github.com/microsoft/autogen int…
Jan 1, 2024
a7813d8
minor change
Jan 1, 2024
1928168
Add more detailed description
Jan 1, 2024
1d82c04
add docker instructions
qingyun-wu Jan 2, 2024
5855d59
more dockerfiles
qingyun-wu Jan 2, 2024
05ad1f0
readme update
qingyun-wu Jan 2, 2024
71ba44b
latest python
qingyun-wu Jan 2, 2024
2235094
dev docker python version
qingyun-wu Jan 2, 2024
59222e9
Merge branch 'main' into add-docker
qingyun-wu Jan 3, 2024
7ec37a6
add version
qingyun-wu Jan 3, 2024
ec9f2b8
readme
qingyun-wu Jan 3, 2024
465cabe
improve doc
qingyun-wu Jan 3, 2024
9ce2b80
improve doc
qingyun-wu Jan 3, 2024
ef99ea2
path name
qingyun-wu Jan 3, 2024
5354911
naming
qingyun-wu Jan 3, 2024
3559f19
Update website/docs/Installation.md
qingyun-wu Jan 4, 2024
51b4082
Update website/docs/Installation.md
qingyun-wu Jan 4, 2024
97ef73d
Add suggestion to install colima for Mac users
Jan 4, 2024
1d55fc4
Update website/docs/Installation.md
qingyun-wu Jan 4, 2024
662aca8
Update website/docs/Installation.md
qingyun-wu Jan 4, 2024
c2c892d
update doc
qingyun-wu Jan 4, 2024
539bed5
Merge branch 'add-docker' of https://github.com/microsoft/autogen int…
qingyun-wu Jan 4, 2024
646dcda
typo
qingyun-wu Jan 4, 2024
719435c
improve doc
qingyun-wu Jan 4, 2024
7815c68
add more options in dev file
qingyun-wu Jan 4, 2024
52329f7
contrib
qingyun-wu Jan 4, 2024
0f5e02c
add link to doc
qingyun-wu Jan 4, 2024
46e77a1
add link
qingyun-wu Jan 4, 2024
d019604
Merge branch 'main' into add-docker
qingyun-wu Jan 4, 2024
7e60265
Merge remote-tracking branch 'origin/main' into add-docker
qingyun-wu Jan 7, 2024
4f8e086
Update website/docs/Installation.md
qingyun-wu Jan 7, 2024
0941445
Update website/docs/Installation.md
qingyun-wu Jan 7, 2024
716a5a0
instruction
qingyun-wu Jan 7, 2024
7f0d63d
Update website/docs/FAQ.md
qingyun-wu Jan 7, 2024
9d90e75
FAQ
qingyun-wu Jan 7, 2024
7c49f31
comment autogen studio
qingyun-wu Jan 7, 2024
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
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License. See LICENSE file in the project root for license information.
#-------------------------------------------------------------------------------------------------------------

FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.10
FROM mcr.microsoft.com/vscode/devcontainers/python:3.10-bookworm
qingyun-wu marked this conversation as resolved.
Show resolved Hide resolved

#
# Update the OS and maybe install packages
Expand Down
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,13 @@ The easiest way to start playing is
2. Copy OAI_CONFIG_LIST_sample to ./notebook folder, name to OAI_CONFIG_LIST, and set the correct configuration.
3. Start playing with the notebooks!

## Using existing docker image
Install docker, save your oai key into an environment variable name OPENAI_API_KEY, and then run the following.

```
docker pull yuandongtian/autogen:latest
docker run -it -e OPENAI_API_KEY=$OPENAI_API_KEY -p 8081:8081 docker.io/yuandongtian/autogen:latest
```
## Installation

Then open `http://localhost:8081/` in your browser to use AutoGen. The UI is from `./samples/apps/autogen-assistant`. See docker hub [link](https://hub.docker.com/r/yuandongtian/autogen) for more details.
### Option 1. Run AutoGen in Docker (recommended)

## Installation
Find detailed instructions for users [here](https://microsoft.github.io/autogen/docs/Installation#option-1-using-docker), and for developers [here](https://microsoft.github.io/autogen/docs/Contribute#docker).

### Option 2. Install AutoGen without Docker
AutoGen requires **Python version >= 3.8, < 3.12**. It can be installed from pip:

```bash
Expand Down
21 changes: 21 additions & 0 deletions samples/dockers/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM python:3.11-slim-bookworm

RUN : \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
software-properties-common \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python3-venv \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& :

RUN python3 -m venv /venv
ENV PATH=/venv/bin:$PATH
EXPOSE 8081

RUN cd /venv; pip install pyautogen
# Pre-load popular packages as per https://learnpython.com/blog/most-popular-python-packages/
RUN pip install numpy pandas matplotlib seaborn scikit-learn requests urllib3 nltk pillow pytest beautifulsoup4

ENTRYPOINT []
9 changes: 6 additions & 3 deletions Dockerfile → samples/dockers/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# basic setup
FROM python:3.10
FROM python:3.11-slim-bookworm
RUN apt-get update && apt-get -y update
RUN apt-get install -y sudo git npm

Expand All @@ -13,8 +13,8 @@ USER autogen-dev
RUN cd /home/autogen-dev && git clone https://github.com/microsoft/autogen.git
WORKDIR /home/autogen-dev/autogen

# Install autogen (Note: extra components can be installed if needed)
RUN sudo pip install -e .[test]
# Install autogen in editable mode (Note: extra components can be installed if needed)
RUN sudo pip install -e .[test,teachable,lmm,graphs]
qingyun-wu marked this conversation as resolved.
Show resolved Hide resolved

# Install precommit hooks
RUN pre-commit install
Expand All @@ -25,6 +25,9 @@ RUN sudo pip install pydoc-markdown
RUN cd website
RUN yarn install --frozen-lockfile --ignore-engines

# Pre-load popular packages as per https://learnpython.com/blog/most-popular-python-packages/
RUN pip install numpy pandas matplotlib seaborn scikit-learn requests urllib3 nltk pillow pytest beautifulsoup4

# override default image starting point
CMD /bin/bash
ENTRYPOINT []
21 changes: 21 additions & 0 deletions samples/dockers/Dockerfile.full
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM python:3.11-slim-bookworm

RUN : \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
software-properties-common \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python3-venv \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& :

RUN python3 -m venv /venv
ENV PATH=/venv/bin:$PATH
EXPOSE 8081

RUN cd /venv; pip install pyautogen[teachable,lmm,graphs,retrievechat,mathchat,blendsearch] autogenra
# Pre-load popular packages as per https://learnpython.com/blog/most-popular-python-packages/
RUN pip install numpy pandas matplotlib seaborn scikit-learn requests urllib3 nltk pillow pytest beautifulsoup4

ENTRYPOINT []
12 changes: 9 additions & 3 deletions website/docs/Contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,19 @@ pip install -e autogen

### Docker

We provide a simple [Dockerfile](https://github.com/microsoft/autogen/blob/main/Dockerfile).
We provide [Dockerfiles](https://github.com/microsoft/autogen/blob/main/sample/dockers/Dockerfile.dev) for developers to use.

Use the following command line to build and run a docker image.

```
docker build -f sample/docker/Dockerfile.dev -t autogen_dev_img https://github.com/microsoft/autogen.git

```bash
docker build https://github.com/microsoft/autogen.git#main -t autogen-dev
docker run -it autogen-dev
```

Detailed instructions can be found [here](Installation.md#option-1-using-docker-recommended)
qingyun-wu marked this conversation as resolved.
Show resolved Hide resolved


### Develop in Remote Container

If you use vscode, you can open the autogen folder in a [Container](https://code.visualstudio.com/docs/remote/containers).
Expand Down
49 changes: 45 additions & 4 deletions website/docs/Installation.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,51 @@
# Installation

## Setup Virtual Environment
## Option 1: Using Docker (Recommended)
#### Step 1. Install [docker](https://www.docker.com/).

Docker is recommended as a properly built docker image could provide isolated and consistent environment to run your code securely across platforms. Install docker following [this instruction](https://docs.docker.com/get-docker/).

#### Step 2. Build a docker image

AutoGen provides [dockerfiles](https://github.com/microsoft/autogen/tree/main/samples/dockers/) that could be used to built docker images. Use the following command line to build a docker image named `autogen_img` (or some other name you like) one of the provided dockerfiles named `Dockerfile.baes`:
qingyun-wu marked this conversation as resolved.
Show resolved Hide resolved
```
docker build -f sample/docker/Dockerfile.base -t autogen_img https://github.com/microsoft/autogen.git
ekzhu marked this conversation as resolved.
Show resolved Hide resolved
```
which includes some common python libraries and essential dependencies of AutoGen, or build from `Dockerfile.full` which include additional dependencies for more advanced features of AutoGen with the following command line:

```
docker build -f sample/docker/Dockerfile.full -t autogen_img https://github.com/microsoft/autogen.git
```
Once you build the docker image, you can use `docker images` to check whether it has been created successfully.

#### Step 3. Run applications built with AutoGen from a docker image.

**Save keys into environment variable:**
If your application needs an oai key, save your oai key into an environment variable `OPENAI_API_KEY`, which can be done by adding the following line in your `~/.bashrc` (or `~/.zshrc`),

```
export OPENAI_API_KEY="sk-xxxxxx"
```
qingyun-wu marked this conversation as resolved.
Show resolved Hide resolved

**Mount your code to the docker image and run your application from there:** Now suppose you have your application built with AutoGen in a folder named `myapp`. You can mount it into the docker image and run it. In the example below, the folder `myapp` is mounted into `/myapp` in the docker, and the script `main_twoagent.py` is executed in the docker.

```python
# Mount the local folder `myapp` into docker image and run the script in the docker.
docker run -it -e OPENAI_API_KEY=$OPENAI_API_KEY -v `pwd`/myapp:/myapp autogen_img:latest python /myapp/main_twoagent.py
```

Similarly, you may also run [AutoGen Studio](https://github.com/microsoft/autogen/tree/main/samples/apps/autogen-studio) as below:

```
docker run -it -e OPENAI_API_KEY=$OPENAI_API_KEY -p 8081:8081 autogen_img:latest autogenra ui --host 0.0.0.0
```
Then open `http://localhost:8081/` in your browser to use AutoGen assistant.
qingyun-wu marked this conversation as resolved.
Show resolved Hide resolved

## Option 2: Use Virtual Environment

When not using a docker container, we recommend using a virtual environment to install AutoGen. This will ensure that the dependencies for AutoGen are isolated from the rest of your system.
sonichi marked this conversation as resolved.
Show resolved Hide resolved

### Option 1: venv
### Option a: venv

You can create a virtual environment with `venv` as below:
```bash
Expand All @@ -17,7 +58,7 @@ The following command will deactivate the current `venv` environment:
deactivate
```

### Option 2: conda
### Option b: conda

Another option is with `Conda`, Conda works better at solving dependency conflicts than pip. You can install it by following [this doc](https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html),
qingyun-wu marked this conversation as resolved.
Show resolved Hide resolved
and then create a virtual environment as below:
Expand All @@ -31,7 +72,7 @@ The following command will deactivate the current `conda` environment:
conda deactivate
```

### Option 3: poetry
### Option c: poetry

Another option is with `poetry`, which is a dependency manager for Python.

Expand Down
Loading