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

Optimize DockerfileBase for Improved Efficiency and Reduced Size #651

Merged

Conversation

PeterDaveHello
Copy link
Contributor

This pull request includes three commits that collectively optimize the DockerfileBase. The changes are focused on improving the build process, reducing the Docker image size, and maintaining consistency across the Dockerfile commands.
Optimize DockerfileBase for Image Efficiency

  • Add the --no-cache-dir flag to pip install --upgrade pip to align with other pip installation commands, prevent caching, and reduce Docker image layer size.
  • Move Tesseract-OCR files to '/usr/share/tesseract-ocr-original' to prevent redundant operations and improve the efficiency of the backup process.
  • Clean the apt cache within the same RUN statement after package installations by including rm -rf /var/lib/apt/lists/*, ensuring a reduced Docker image size by avoiding the retention of transient package data.

These changes contribute to a more efficient build process and a minimized Docker image, aligning with best practices for Dockerfile maintenance and deployment.

License Agreement for Contributions

By submitting this pull request, I acknowledge and agree that my contributions will be included in Stirling-PDF and that they can be relicensed in the future under MPL 2.0 (Mozilla Public License Version 2.0) license.

(This does not change the general open-source nature of Stirling-PDF, simply moving from one license to another license)

Changes include:
- Cleaning up the apt cache by adding `rm -rf /var/lib/apt/lists/*`
  after each package installation within the same RUN statement.
- Ensuring the Docker image size is minimized by removing unnecessary
  files immediately after use.

These adjustments will result in a more space-efficient Docker image.
Aligned pip upgrade command with others by adding the `--no-cache-dir`
flag to reduce image layer size.
@PeterDaveHello
Copy link
Contributor Author

Docker image size before and after the change, a little bit smaller:

REPOSITORY          TAG                 IMAGE ID       CREATED          SIZE
base                after               91bee49112b9   19 hours ago     1.58GB
base                before              767036aed57a   20 hours ago     1.64GB

@Frooodle
Copy link
Member

Frooodle commented Jan 5, 2024

Plan to go with
#624
which will depreciate this PR

But will merge for now, appreciate the help!

@Frooodle Frooodle closed this Jan 5, 2024
@Frooodle Frooodle reopened this Jan 5, 2024
@Frooodle Frooodle merged commit b5e0e14 into Stirling-Tools:main Jan 5, 2024
5 checks passed
@PeterDaveHello PeterDaveHello deleted the OptimizeDockerfile branch January 6, 2024 17:34
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.

None yet

2 participants