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

Make the docker setup consistent with local #1199

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
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
32 changes: 10 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
# Use an official Python base image from the Docker Hub
FROM python:3.10-slim

# Install git
RUN apt-get -y update
RUN apt-get -y install git chromium-driver
RUN apt-get update
RUN apt-get install -y git chromium-driver wget gnupg2 libgtk-3-0 libdbus-glib-1-2 dbus-x11 xvfb ca-certificates
Copy link
Member

@Pwuts Pwuts Apr 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer keeping X11 and the Xvfb etc out of the docker image, as docker containers are headless anyways, and clearly state in the docs that only headless browsing is supported in the docker container. Headless browsing should work fine since #1473.


# Install Xvfb and other dependencies for headless browser testing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was actually useful imo, can you add it back in some form?

RUN apt-get update \
&& apt-get install -y wget gnupg2 libgtk-3-0 libdbus-glib-1-2 dbus-x11 xvfb ca-certificates

# Install Firefox / Chromium
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& 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
Comment on lines 6 to 9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chromium is already installed by apt-get install chromium-driver. This might entirely be replaced by apt-get install -y firefox-esr.

Suggested change
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& 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
RUN apt-get install -y firefox-esr


# Set environment variables
ENV PIP_NO_CACHE_DIR=yes \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1

# Create a non-root user and set permissions
RUN useradd --create-home appuser
WORKDIR /home/appuser
RUN chown appuser:appuser /home/appuser
USER appuser
WORKDIR /tmp
COPY requirements.txt .

# Chop out the part of requirements.txt not intended for the docker image
RUN sed -i '/Items below this point will not be included in the Docker Image/,$d' requirements.txt
RUN pip install -r requirements.txt

# Copy the requirements.txt file and install the requirements
COPY --chown=appuser:appuser 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 --user -r requirements.txt
WORKDIR /app

# Copy the application files
COPY --chown=appuser:appuser autogpt/ ./autogpt
COPY . .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need all files in the container build. docker-compose.yml contains a non-selective volume mount, that's fine because it is intended for local use. Please be more selective here though, since we will be shipping images using this config.


# Set the entrypoint
ENTRYPOINT ["python", "-m", "autogpt"]
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ services:
env_file:
- .env
Comment on lines 10 to 11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since redis is started by default, it seems logical to also connect redis by default. This will be overridden by any explicit settings in .env.

Suggested change
env_file:
- .env
env_file:
- .env
environment:
MEMORY_BACKEND: ${MEMORY_BACKEND:-redis}
REDIS_HOST: ${REDIS_HOST:-redis}

volumes:
- "./autogpt:/app"
- ".env:/app/.env"
profiles: ["exclude-from-up"]
- "./:/app"
profiles: ["exclude-from-up"] # Run and attach to container instead with: `docker-compose run auto-gpt`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
profiles: ["exclude-from-up"] # Run and attach to container instead with: `docker-compose run auto-gpt`
profiles: ["exclude-from-up"] # Run and attach to container instead with: `docker-compose run --rm auto-gpt`

--rm to prevent 1001 dead containers


redis:
image: "redis/redis-stack-server:latest"