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

Improve Dockerfile with best practices and optimizations #1231

Merged

Conversation

sunnypranay
Copy link
Contributor

Background

The existing Dockerfile in the project can be improved by incorporating best practices and optimizations, such as using a non-root user, setting appropriate environment variables, and reducing image size by disabling caching. These changes will make the Dockerfile more secure, efficient, and compliant with best practices.

Changes

  • Added environment variables to prevent Python from buffering the output and to disable writing .pyc files.

  • Created a non-root user named appuser to follow the principle of least privilege and updated the ownership of files and folders accordingly.

  • Added the --no-cache-dir flag to the pip install command to prevent caching and reduce the image size.

  • Updated the COPY command to set the appropriate user and group ownership for the copied files.

Documentation

The changes have been explained in this pull request description. The improved Dockerfile itself includes comments that explain the purpose of each command and environment variable.

Test Plan

  1. Build the Docker image using the updated Dockerfile with the command docker build -t improved-dockerfile ..

  2. Run a container using the newly built image with docker run --rm -it improved-dockerfile.

  3. Verify that the application runs as expected within the container, and that any relevant functionality still works as intended.

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

@richbeales richbeales merged commit cba2760 into Significant-Gravitas:master Apr 14, 2023
@mikekelly
Copy link
Contributor

This test plan didn't account for docker-compose usage, which it broke. This optimisation caused a bunch of regressions and didn't appear to provide any meaningful benefit.

@KissPeter
Copy link
Contributor

--no-cache-dir is not necessary if PIP_NO_CACHE_DIR is set

@nponeccop
Copy link
Contributor

@KissPeter You can switch to the Files Changed tab and do a code review commenting on the lines and even requiring changes. It doesn't require any privileges.

@nponeccop
Copy link
Contributor

Well, it's too late here. But you can file an issue :)

@mikekelly
Copy link
Contributor

@KissPeter all of this is cleaned up by #1199

@nponeccop nponeccop mentioned this pull request Apr 14, 2023
1 task
sindlinger pushed a commit to Orgsindlinger/Auto-GPT-WebUI that referenced this pull request Sep 25, 2024
…d-dockerfile

Improve Dockerfile with best practices and optimizations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants