Improve docker setup & config (#1843)

* Improve docker setup & config

* fix(browsing): Selenium needs access to home directory

* fix(docker): allow overriding memory backend settings

* simplify Dockerfile and docker-compose config

* add .dockerignore

* adjust Docker CI with release build type arg

* replace Chrome by Chromium in devcontainer

* update docs

* update bulletin

* use preinstalled chromedriver in web_selenium.py

* update installation.md

* fix code blocks for mkdocs

* fix links to docs
This commit is contained in:
Reinier van der Leer
2023-04-24 15:27:53 +02:00
committed by GitHub
parent f8dfedf1c6
commit 9c60eecce6
10 changed files with 133 additions and 105 deletions

View File

@@ -1,6 +1,6 @@
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3-bullseye, 3.10-bullseye, 3-buster, 3.10-buster # [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3-bullseye, 3.10-bullseye, 3-buster, 3.10-buster
ARG VARIANT=3-bullseye ARG VARIANT=3-bullseye
FROM --platform=linux/amd64 python:3.10 FROM python:3.10
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131 # Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
@@ -10,10 +10,8 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# They are installed by the base image (python) which does not have the patch. # They are installed by the base image (python) which does not have the patch.
RUN python3 -m pip install --upgrade setuptools RUN python3 -m pip install --upgrade setuptools
# Install Chrome for web browsing # Install Chromium for web browsing
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ RUN apt-get install -y chromium-driver
&& curl -sSL https://dl.google.com/linux/direct/google-chrome-stable_current_$(dpkg --print-architecture).deb -o /tmp/chrome.deb \
&& apt-get -y install /tmp/chrome.deb
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. # [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/ # COPY requirements.txt /tmp/pip-tmp/

8
.dockerignore Normal file
View File

@@ -0,0 +1,8 @@
.*
*.template
*.yaml
*.yml
*.md
*.png
!BULLETIN.md

View File

@@ -18,4 +18,4 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Build the Docker image - name: Build the Docker image
run: docker build . --file Dockerfile --tag autogpt:$(date +%s) run: docker build . --build-arg BUILD_TYPE=release --tag autogpt:$(date +%s)

View File

@@ -1,2 +1,5 @@
Welcome to Auto-GPT! We'll keep you informed of the latest news and features by printing messages here. Welcome to Auto-GPT! We'll keep you informed of the latest news and features by printing messages here.
If you don't wish to see this message, you can run Auto-GPT with the --skip-news flag If you don't wish to see this message, you can run Auto-GPT with the --skip-news flag
## Changes to Docker configuration
The workdir has been changed from /home/appuser to /app. Be sure to update any volume mounts accordingly.

View File

@@ -1,38 +1,33 @@
# Use an official Python base image from the Docker Hub # Use an official Python base image from the Docker Hub
FROM python:3.10-slim FROM python:3.10-slim
# Install git # 'dev' or 'release' container build
RUN apt-get -y update ARG BUILD_TYPE=dev
RUN apt-get -y install git chromium-driver
# Install Xvfb and other dependencies for headless browser testing # Install browsers
RUN apt-get update \ RUN apt-get update && apt-get install -y \
&& apt-get install -y wget gnupg2 libgtk-3-0 libdbus-glib-1-2 dbus-x11 xvfb ca-certificates chromium-driver firefox-esr \
ca-certificates
# Install Firefox / Chromium # Install utilities
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ RUN apt-get install -y curl jq wget git
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update \
&& apt-get install -y chromium firefox-esr
# Set environment variables # Set environment variables
ENV PIP_NO_CACHE_DIR=yes \ ENV PIP_NO_CACHE_DIR=yes \
PYTHONUNBUFFERED=1 \ PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 PYTHONDONTWRITEBYTECODE=1
# Create a non-root user and set permissions # Install the required python packages globally
RUN useradd --create-home appuser ENV PATH="$PATH:/root/.local/bin"
WORKDIR /home/appuser COPY requirements.txt .
RUN chown appuser:appuser /home/appuser
USER appuser
# Copy the requirements.txt file and install the requirements # Only install dev dependencies in dev container builds
COPY --chown=appuser:appuser requirements.txt . RUN [ '${BUILD_TYPE}' = 'dev' ] || sed -i '/Items below this point will not be included in the Docker Image/,$d' requirements.txt && \
RUN sed -i '/Items below this point will not be included in the Docker Image/,$d' requirements.txt && \ pip install --no-cache-dir -r requirements.txt
pip install --no-cache-dir --user -r requirements.txt
# Copy the application files # Copy the application files
COPY --chown=appuser:appuser autogpt/ ./autogpt WORKDIR /app
COPY autogpt/ ./autogpt
# Set the entrypoint # Set the entrypoint
ENTRYPOINT ["python", "-m", "autogpt"] ENTRYPOINT ["python", "-m", "autogpt"]

View File

@@ -59,37 +59,37 @@ Your support is greatly appreciated. Development of this free, open-source proje
## 📋 Requirements ## 📋 Requirements
- Environment (pick one) Choose an environment to run Auto-GPT in (pick one):
- [Docker](https://docs.docker.com/get-docker/) (*recommended*)
- Python 3.10 or later (instructions: [for Windows](https://www.tutorialspoint.com/how-to-install-python-in-windows)) - Python 3.10 or later (instructions: [for Windows](https://www.tutorialspoint.com/how-to-install-python-in-windows))
- Docker [Docker Hub](https://hub.docker.com/r/significantgravitas/auto-gpt)
- [VSCode + devcontainer](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) - [VSCode + devcontainer](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
## Quickstart ## Quickstart
1. Set up your OpenAI [API Keys](https://platform.openai.com/account/api-keys) 1. Set up your OpenAI [API Keys](https://platform.openai.com/account/api-keys)
2. Download the [latest release](https://github.com/Significant-Gravitas/Auto-GPT/releases/latest) 2. Download the [latest release](https://github.com/Significant-Gravitas/Auto-GPT/releases/latest)
3. Install the [dependencies](/docs/installation.md) and set your [environment variables](/docs/installation.md) 3. Follow the [installation instructions][docs/install]
4. Configure any additional features you want, or install some [plugins](/docs/plugins.md) 4. Configure any additional features you want, or install some [plugins][docs/plugins]
5. [Run](/docs/usage.md) the app 5. [Run][docs/usage] the app
Please see the [documentation](/docs) linked below for full setup instructions and configuration options. Please see the [documentation][docs] linked below for full setup instructions and configuration options.
## 💾 Documentation [docs]: https://significant-gravitas.github.io/Auto-GPT/
[Installation](/docs/installation.md) ## 📖 Documentation
* [⚙️ Installation][docs/install]
[Usage](/docs/usage.md) * [💻 Usage][docs/usage]
* [🔌 Plugins][docs/plugins]
[Speech](/docs/configuration/voice.md) * Configuration
* [🔍 Web Search](https://significant-gravitas.github.io/Auto-GPT/configuration/search/)
[Search](/docs/configuration/search.md) * [🧠 Memory](https://significant-gravitas.github.io/Auto-GPT/configuration/memory/)
* [🗣️ Voice (TTS)](https://significant-gravitas.github.io/Auto-GPT/configuration/voice/)
[Plugins](/docs/plugins.md) * [🖼️ Image Generation](https://significant-gravitas.github.io/Auto-GPT/configuration/imagegen/)
[Memory](/docs/configuration/memory.md)
[Image Generation](/docs/configuration/imagegen.md)
[docs/install]: https://significant-gravitas.github.io/Auto-GPT/installation/
[docs/usage]: https://significant-gravitas.github.io/Auto-GPT/usage/
[docs/plugins]: https://significant-gravitas.github.io/Auto-GPT/plugins/
## ⚠️ Limitations ## ⚠️ Limitations

View File

@@ -95,8 +95,13 @@ def scrape_text_with_selenium(url: str) -> tuple[WebDriver, str]:
options.add_argument("--headless") options.add_argument("--headless")
options.add_argument("--disable-gpu") options.add_argument("--disable-gpu")
chromium_driver_path = Path("/usr/bin/chromedriver")
driver = webdriver.Chrome( driver = webdriver.Chrome(
executable_path=ChromeDriverManager().install(), options=options executable_path=chromium_driver_path
if chromium_driver_path.exists()
else ChromeDriverManager().install(),
options=options,
) )
driver.get(url) driver.get(url)

View File

@@ -9,9 +9,11 @@ services:
build: ./ build: ./
env_file: env_file:
- .env - .env
environment:
MEMORY_BACKEND: ${MEMORY_BACKEND:-redis}
REDIS_HOST: ${REDIS_HOST:-redis}
volumes: volumes:
- "./autogpt:/home/appuser" - ./:/app
- ".env:/home/appuser/.env"
profiles: ["exclude-from-up"] profiles: ["exclude-from-up"]
redis: redis:

View File

@@ -11,48 +11,39 @@ You can set up paid account at https://platform.openai.com/account/billing/overv
Important: It's highly recommended that you track your usage on [the Usage page](https://platform.openai.com/account/usage) Important: It's highly recommended that you track your usage on [the Usage page](https://platform.openai.com/account/usage)
You can also set limits on how much you spend on [the Usage limits page](https://platform.openai.com/account/billing/limits). You can also set limits on how much you spend on [the Usage limits page](https://platform.openai.com/account/billing/limits).
![For OpenAI API key to work, set up paid account at OpenAI API > Billing](./docs/imgs/openai-api-key-billing-paid-account.png) ![For OpenAI API key to work, set up paid account at OpenAI API > Billing](./imgs/openai-api-key-billing-paid-account.png)
**PLEASE ENSURE YOU HAVE DONE THIS STEP BEFORE PROCEEDING. OTHERWISE, NOTHING WILL WORK!** **PLEASE ENSURE YOU HAVE DONE THIS STEP BEFORE PROCEEDING. OTHERWISE, NOTHING WILL WORK!**
## Steps ## General setup
To install Auto-GPT, follow these steps: 1. Make sure you have one of the environments listed under [**requirements**](../README.md#-requirements) set up.
1. Make sure you have all the **requirements** listed in the [README](../README.md). If not, install/get them. _To execute the following commands, open a CMD, Bash, or Powershell window by navigating to a folder on your computer and typing `CMD` in the folder path at the top, then press enter._
_To execute the following commands, open a CMD, Bash, or Powershell window by navigating to a folder on your computer and typing `CMD` in the folder path at the top, then press enter._ 2. Clone the repository using Git, or download the [latest stable release](https://github.com/Significant-Gravitas/Auto-GPT/releases/latest) (`Source code (zip)`, at the bottom of the page).
2. Clone the repository: For this step, you need Git installed. ``` shell
Note: If you don't have Git, you can just download the [latest stable release](https://github.com/Significant-Gravitas/Auto-GPT/releases/latest) instead (`Source code (zip)`, at the bottom of the page).
``` shell
git clone -b stable https://github.com/Significant-Gravitas/Auto-GPT.git git clone -b stable https://github.com/Significant-Gravitas/Auto-GPT.git
``` ```
3. Navigate to the directory where you downloaded the repository. 3. Navigate to the directory where you downloaded the repository.
``` shell ``` shell
cd Auto-GPT cd Auto-GPT
``` ```
4. Install the required dependencies.
``` shell
pip install -r requirements.txt
```
5. Configure Auto-GPT: 5. Configure Auto-GPT:
1. Find the file named `.env.template` in the main /Auto-GPT folder. This file may be hidden by default in some operating systems due to the dot prefix. To reveal hidden files, follow the instructions for your specific operating system (e.g., in Windows, click on the "View" tab in File Explorer and check the "Hidden items" box; in macOS, press Cmd + Shift + .). 1. Find the file named `.env.template` in the main `Auto-GPT` folder. This file may be hidden by default in some operating systems due to the dot prefix. To reveal hidden files, follow the instructions for your specific operating system (e.g., in Windows, click on the "View" tab in File Explorer and check the "Hidden items" box; in macOS, press Cmd + Shift + .).
2. Create a copy of this file and call it `.env` by removing the `template` extension. The easiest way is to do this in a command prompt/terminal window `cp .env.template .env`. 2. Create a copy of this file and call it `.env` by removing the `template` extension. The easiest way is to do this in a command prompt/terminal window `cp .env.template .env`.
3. Open the `.env` file in a text editor. 3. Open the `.env` file in a text editor.
4. Find the line that says `OPENAI_API_KEY=`. 4. Find the line that says `OPENAI_API_KEY=`.
5. After the `"="`, enter your unique OpenAI API Key (without any quotes or spaces). 5. After the `"="`, enter your unique OpenAI API Key (without any quotes or spaces).
6. Enter any other API keys or Tokens for services you would like to use. 6. Enter any other API keys or Tokens for services you would like to use. To activate and adjust a setting, remove the `# ` prefix.
7. Save and close the `.env` file. 7. Save and close the `.env` file.
After you complete these steps, you'll have properly configured the API keys for your project. You have now configured Auto-GPT.
Notes: Notes:
- See [OpenAI API Keys Configuration](#openai-api-keys-configuration) to get your OpenAI API key. - See [OpenAI API Keys Configuration](#openai-api-keys-configuration) to get your OpenAI API key.
- Get your ElevenLabs API key from: https://elevenlabs.io. You can view your xi-api-key using the "Profile" tab on the website. - Get your ElevenLabs API key from: https://elevenlabs.io. You can view your xi-api-key using the "Profile" tab on the website.
@@ -61,38 +52,54 @@ Note: If you don't have Git, you can just download the [latest stable release](h
- `fast_llm_model_deployment_id` - your gpt-3.5-turbo or gpt-4 deployment ID - `fast_llm_model_deployment_id` - your gpt-3.5-turbo or gpt-4 deployment ID
- `smart_llm_model_deployment_id` - your gpt-4 deployment ID - `smart_llm_model_deployment_id` - your gpt-4 deployment ID
- `embedding_model_deployment_id` - your text-embedding-ada-002 v2 deployment ID - `embedding_model_deployment_id` - your text-embedding-ada-002 v2 deployment ID
- Please specify all of these values as double-quoted strings - Please specify all of these values as double-quoted strings
``` shell
``` shell # Replace string in angled brackets (<>) to your own ID
# Replace string in angled brackets (<>) to your own ID azure_model_map:
azure_model_map: fast_llm_model_deployment_id: "<my-fast-llm-deployment-id>"
fast_llm_model_deployment_id: "<my-fast-llm-deployment-id>" ...
... ```
```
- Details can be found here: https://pypi.org/project/openai/ in the `Microsoft Azure Endpoints` section and here: https://learn.microsoft.com/en-us/azure/cognitive-services/openai/tutorials/embeddings?tabs=command-line for the embedding model. - Details can be found here: https://pypi.org/project/openai/ in the `Microsoft Azure Endpoints` section and here: https://learn.microsoft.com/en-us/azure/cognitive-services/openai/tutorials/embeddings?tabs=command-line for the embedding model.
- If you're on Windows you may need to install https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170 - If you're on Windows you may need to install https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170
## Docker 4. Follow the further instructions for running Auto-GPT with [Docker](#run-with-docker) (*recommended*), or [Docker-less](#run-docker-less)
You can also build this into a docker image and run it: ### Run with Docker
Easiest is to run with `docker-compose`:
``` shell ``` shell
docker build -t autogpt . docker-compose build auto-gpt
docker run -it --env-file=./.env -v $PWD/auto_gpt_workspace:/home/appuser/auto_gpt_workspace autogpt docker-compose run --rm auto-gpt
``` ```
By default, this will also start and attach a Redis memory backend.
For related settings, see [Memory > Redis setup](./configuration/memory.md#redis-setup).
Or if you have `docker-compose`: You can also build and run it with "vanilla" docker commands:
``` shell ``` shell
docker-compose run --build --rm auto-gpt docker build -t auto-gpt .
docker run -it --env-file=.env -v $PWD:/app auto-gpt
``` ```
You can pass extra arguments, for instance, running with `--gpt3only` and `--continuous` mode: You can pass extra arguments, for instance, running with `--gpt3only` and `--continuous` mode:
``` shell ``` shell
docker run -it --env-file=./.env -v $PWD/auto_gpt_workspace:/home/appuser/auto_gpt_workspace autogpt --gpt3only --continuous docker-compose run --rm auto-gpt --gpt3only --continuous
``` ```
``` shell ``` shell
docker-compose run --build --rm auto-gpt --gpt3only --continuous docker run -it --env-file=.env -v $PWD:/app --rm auto-gpt --gpt3only --continuous
``` ```
Alternatively, you can pull the latest release directly from [Docker Hub](https://hub.docker.com/r/significantgravitas/auto-gpt) Alternatively, you can pull the latest release directly from [Docker Hub](https://hub.docker.com/r/significantgravitas/auto-gpt) and run that:
``` shell
docker run -it --env OPENAI_API_KEY='your-key-here' --rm significantgravitas/auto-gpt
```
Or with `ai_settings.yml` presets mounted:
``` shell
docker run -it --env OPENAI_API_KEY='your-key-here' -v $PWD/ai_settings.yaml:/app/ai_settings.yaml --rm significantgravitas/auto-gpt
```
### Run Docker-less
Simply run `./run.sh` (Linux/macOS) or `.\run.bat` (Windows) in your terminal.

View File

@@ -1,15 +1,25 @@
# Usage # Usage
1. Run the `autogpt` Python module in your terminal. 1. Open a terminal and run the startup script:
* On Linux/MacOS: * On Linux/MacOS:
``` ``` shell
./run.sh ./run.sh
``` ```
* On Windows: * On Windows:
``` ``` shell
.\run.bat .\run.bat
``` ```
Running with `--help` after `.\run.bat` lists all the possible command line arguments you can pass. * Using Docker:
``` shell
docker-compose run --rm auto-gpt
```
Running with `--help` lists all the possible command line arguments you can pass:
``` shell
./run.sh --help
# or with docker
docker-compose run --rm auto-gpt --help
```
2. After each response from Auto-GPT, choose from the options to authorize command(s), 2. After each response from Auto-GPT, choose from the options to authorize command(s),
exit the program, or provide feedback to the AI. exit the program, or provide feedback to the AI.
@@ -24,15 +34,15 @@ Here are some common arguments you can use when running Auto-GPT:
> Replace anything in angled brackets (<>) to a value you want to specify > Replace anything in angled brackets (<>) to a value you want to specify
* View all available command line arguments * View all available command line arguments
``` ``` shell
python -m autogpt --help python -m autogpt --help
``` ```
* Run Auto-GPT with a different AI Settings file * Run Auto-GPT with a different AI Settings file
``` ``` shell
python -m autogpt --ai-settings <filename> python -m autogpt --ai-settings <filename>
``` ```
* Specify a memory backend * Specify a memory backend
``` ``` shell
python -m autogpt --use-memory <memory-backend> python -m autogpt --use-memory <memory-backend>
``` ```
@@ -55,7 +65,7 @@ Use at your own risk.
1. Run the `autogpt` python module in your terminal: 1. Run the `autogpt` python module in your terminal:
``` ``` shell
python -m autogpt --continuous python -m autogpt --continuous
``` ```
@@ -85,4 +95,4 @@ To print out debug logs:
``` shell ``` shell
python -m autogpt --debug python -m autogpt --debug
``` ```