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

Conversation

mikekelly
Copy link
Contributor

@mikekelly mikekelly commented Apr 13, 2023

Background

The project structure in Docker was different from local setup for no apparent reason, this brings it in line and cleans things up.

Changes

  • Dockerfile now copies the full directory in to the container
  • The docker-compose volume configuration was simplified.
  • Only calling apt-get update and apt-get install once each
  • Separating apt-get update and apt-get install into separate steps so the former can hit docker cache when building
  • Install deps globally using /tmp dir to adjust the requirements.txt file to remove non Docker deps
  • Use conventional /app dir
  • Revert to using root as per base container, resolving permissions issues when creating logs in mounted volume.

Testing

Image built successfully and container ran successfully.

PR Quality Checklist

  • My pull request is atomic and focuses on a single change.
  • I have thoroughly tested my changes with multiple different prompts.
  • I have considered potential risks and mitigations for my changes.
  • I have documented my changes clearly and comprehensively.
  • I have not snuck in any "extra" small tweaks changes

@tech3br
Copy link

tech3br commented Apr 13, 2023

Thanks man! It's useful.

@nponeccop
Copy link
Contributor

@mikekelly There are conflicts now

nponeccop
nponeccop previously approved these changes Apr 14, 2023
scripts/logger.py Outdated Show resolved Hide resolved
nponeccop
nponeccop previously approved these changes Apr 14, 2023
nponeccop
nponeccop previously approved these changes Apr 14, 2023
@nponeccop
Copy link
Contributor

@mikekelly There are conflicts now

@Pwuts Pwuts mentioned this pull request Apr 16, 2023
5 tasks
@nponeccop nponeccop mentioned this pull request Apr 16, 2023
1 task
@github-actions
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Apr 17, 2023
@github-actions
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

2 similar comments
@github-actions
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@github-actions
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@mikekelly
Copy link
Contributor Author

I tried using this but got some permissions issues:

Permission denied: '/home/appuser/app/logs/activity.log

I'm not experiencing this. What are the permissions on the files in that dir? (ls -la)

@mikekelly
Copy link
Contributor Author

You may want to ensure that your working dir is completely clean before using docker-compose run auto-gpt. You can clean the dir of any additionally created files by using git clean -fdx but just be aware this will delete your .env too so make sure you keep a backup of it

@montanaflynn
Copy link
Contributor

@mikekelly the permissions are:

drwxr-xr-x  2 root root  4096 Apr 19 10:33 logs

Also I tried using a fresh git clone, and just making the changes in this pull request and got same error.

I'm running debian 11 and Docker Compose version v2.17.2

docker compose run auto-gpt
[+] Running 1/0
 ✔ Container auto-gpt-redis-1  Running                                                                                                                                                                            0.0s 
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/autogpt/__main__.py", line 6, in <module>
    from autogpt.agent.agent import Agent
  File "/app/autogpt/agent/__init__.py", line 1, in <module>
    from autogpt.agent.agent import Agent
  File "/app/autogpt/agent/agent.py", line 3, in <module>
    from autogpt.app import execute_command, get_command
  File "/app/autogpt/app.py", line 5, in <module>
    from autogpt.agent.agent_manager import AgentManager
  File "/app/autogpt/agent/agent_manager.py", line 7, in <module>
    from autogpt.llm_utils import create_chat_completion
  File "/app/autogpt/llm_utils.py", line 11, in <module>
    from autogpt.logs import logger
  File "/app/autogpt/logs.py", line 202, in <module>
    logger = Logger()
             ^^^^^^^^
  File "/app/autogpt/config/singleton.py", line 15, in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/autogpt/logs.py", line 49, in __init__
    self.file_handler = logging.FileHandler(
                        ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/logging/__init__.py", line 1181, in __init__
    StreamHandler.__init__(self, self._open())
                                 ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/logging/__init__.py", line 1213, in _open
    return open_func(self.baseFilename, self.mode,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/app/logs/activity.log'

@mikekelly
Copy link
Contributor Author

@montanaflynn please can you try this branch (https://github.com/mikekelly/Auto-GPT/tree/docker-permissions-on-linux) in another completely fresh clone and see if it resolves your issue

@montanaflynn
Copy link
Contributor

@mikekelly no permissions issues with that branch, although I did get this warning which I hadn't seen before:

Warning: The file 'AutoGpt.json' does not exist. Local memory would not be saved to a file.

@mikekelly
Copy link
Contributor Author

@montanaflynn I don't think that warning relates to this change

@mikekelly mikekelly changed the title make the docker setup consistent with local Make the docker setup consistent with local Apr 19, 2023
Copy link
Member

@Pwuts Pwuts left a comment

Choose a reason for hiding this comment

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

Looks pretty good. I'd like to request a few tweaks, nothing big though.


# 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?

- ".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

Comment on lines 10 to 11
env_file:
- .env
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}


# 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.

@Pwuts Pwuts removed the bug Something isn't working label Apr 20, 2023
@Pwuts Pwuts self-assigned this Apr 20, 2023
@Pwuts Pwuts mentioned this pull request Apr 20, 2023
1 task
Comment on lines 6 to 9
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
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

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.

@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Apr 21, 2023
@github-actions
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

@Pwuts
Copy link
Member

Pwuts commented Apr 24, 2023

Closing in favor of #1843. Sorry, but we're trying to move quickly and there wasn't any activity on this PR.

@Pwuts Pwuts closed this Apr 24, 2023
SquareandCompass pushed a commit to SquareandCompass/Auto-GPT that referenced this pull request Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conflicts Automatically applied to PRs with merge conflicts docker Obsolete?
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants