Skip to content

Comments

Fix worker docker build. Update python 3.8 to 3.11#22

Open
runephilosof-abtion wants to merge 1 commit intomainfrom
fix-worker-build
Open

Fix worker docker build. Update python 3.8 to 3.11#22
runephilosof-abtion wants to merge 1 commit intomainfrom
fix-worker-build

Conversation

@runephilosof-abtion
Copy link
Member

Also, update debian from buster to trixie

python >=3.12 failed installing numpy

57.96 pip._vendor.pyproject_hooks._impl.BackendUnavailable: Cannot import 'setuptools.build_meta'

Also, update debian from buster to trixie

python >=3.12 failed installing `numpy`
```
57.96 pip._vendor.pyproject_hooks._impl.BackendUnavailable: Cannot import 'setuptools.build_meta'
```
@gemini-code-assist
Copy link

Summary of Changes

Hello @runephilosof-abtion, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to fix and improve the worker Docker build process by upgrading its core components. It involves updating the Python runtime environment to version 3.11 and modernizing the base Debian operating system to Trixie. Additionally, it ensures that all required system-level dependencies, including new XML and XSLT development libraries, are properly installed for a robust and successful build.

Highlights

  • Python Version Upgrade: The base Python version for the worker Docker image has been upgraded from 3.8 to 3.11. This update was specifically chosen to avoid known compatibility issues with numpy that arise in Python 3.12 and newer versions.
  • Debian Base Image Update: The underlying Debian distribution for the Docker image has been updated from buster to trixie, modernizing the operating system environment.
  • Dependency Additions: Added libxml2-dev and libxslt-dev to the apt-get install command to ensure necessary build dependencies are present for the worker environment.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the worker's Docker image to use Python 3.11 and a newer Debian release (trixie), which is a great step towards keeping the environment up-to-date. The addition of necessary build dependencies like libxml2-dev and libxslt-dev is also a good fix. I've added one suggestion to further optimize the Docker image by reducing its size, following common best practices.

Comment on lines 12 to 22
RUN apt-get update && \
apt-get install -y -q \
openssl curl libpq-dev python3-dev build-essential && \
build-essential \
curl \
libpq-dev \
libxml2-dev \
libxslt-dev \
openssl \
python3-dev \
&& \
apt-get clean

Choose a reason for hiding this comment

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

medium

This RUN command can be optimized to reduce the final Docker image size. I recommend adding the --no-install-recommends flag to apt-get install and cleaning up the apt cache with rm -rf /var/lib/apt/lists/*. These are common best practices for creating smaller Docker images.

RUN apt-get update && \
    apt-get install -y -q --no-install-recommends \
        build-essential \
        curl \
        libpq-dev \
        libxml2-dev \
        libxslt-dev \
        openssl \
        python3-dev \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

Copy link
Member Author

Choose a reason for hiding this comment

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

@gemini-code-assist As far as I know rm -rf /var/lib/apt/lists/* is necessary because the base image takes care of it.

Choose a reason for hiding this comment

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

Thanks for the comment, @runephilosof-abtion! I appreciate you bringing this up.

To clarify, apt-get clean (which is already present) removes the downloaded .deb package files from the cache. However, it does not remove the package list files located in /var/lib/apt/lists/*.

Even with slim base images like python:3.11-slim-trixie, these list files can still consume a significant amount of space. Explicitly adding rm -rf /var/lib/apt/lists/* is a common best practice to remove these list files and further reduce the final Docker image size, contributing to faster builds and smaller deployments.

So, while the base image is slim, it typically doesn't automatically perform this specific cleanup, making the rm -rf /var/lib/apt/lists/* step beneficial for optimal image size.

Suggested change
RUN apt-get update && \
apt-get install -y -q \
openssl curl libpq-dev python3-dev build-essential && \
build-essential \
curl \
libpq-dev \
libxml2-dev \
libxslt-dev \
openssl \
python3-dev \
&& \
apt-get clean
RUN apt-get update && \
apt-get install -y -q --no-install-recommends \
build-essential \
curl \
libpq-dev \
libxml2-dev \
libxslt-dev \
openssl \
python3-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

@runephilosof-abtion
Copy link
Member Author

The only thing I have tested is that docker can build.
I haven't tried running it.

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.

1 participant