Skip to content

Commit

Permalink
control-service: optimize job builder pip install (#3151)
Browse files Browse the repository at this point in the history
Pip caching is never useful for Docker builds, and it makes the image
bigger and cause the process to consume more memory which can lead to
OOM errors.
  • Loading branch information
antoniivanov authored Feb 21, 2024
1 parent da4444e commit 6d21c29
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ COPY --chown=$UID:$GID $job_name $job_name/
# TODO: this would trigger for any change in job even if requirements.txt does not change
# but there's no COPY_IF_EXISTS command in docker to try copy it.
ARG requirements_file=requirements.txt
RUN if [ -f "$job_name/$requirements_file" ]; then pip3 install --disable-pip-version-check -q -r "$job_name/$requirements_file" || ( echo ">requirements_failed<" && exit 1 ) ; fi
RUN if [ -f "$job_name/$requirements_file" ]; then pip3 install --no-cache-dir --disable-pip-version-check -q -r "$job_name/$requirements_file" || ( echo ">requirements_failed<" && exit 1 ) ; fi

ARG job_githash
ENV JOB_NAME $job_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ RUN : \
echo "Installing native dependencies ..." \
&& yum install build-essential gcc glibc-devel git freetype2-devel libpng-devel -y \
&& echo "Installing requirements.txt ..." \
&& pip install --disable-pip-version-check -q -r "$job_name/$requirements_file" \
&& pip install --no-cache-dir --disable-pip-version-check -q -r "$job_name/$requirements_file" \
|| ( echo ">requirements_failed<" && exit 1 ) \
&& echo "Removing native dependencies ..." \
&& yum autoremove build-essential gcc glibc-devel git unzip -y \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ COPY --chown=$UID:$GID $job_name $job_name/
# TODO: this would trigger for any change in job even if requirements.txt does not change
# but there's no COPY_IF_EXISTS command in docker to try copy it.
ARG requirements_file=requirements.txt
RUN if [ -f "$job_name/$requirements_file" ]; then pip3 install --disable-pip-version-check -q -r "$job_name/$requirements_file" || ( echo ">requirements_failed<" && exit 1 ) ; fi
RUN if [ -f "$job_name/$requirements_file" ]; then pip3 install --no-cache-dir --disable-pip-version-check -q -r "$job_name/$requirements_file" || ( echo ">requirements_failed<" && exit 1 ) ; fi

ARG job_githash
ENV JOB_NAME $job_name
Expand Down

0 comments on commit 6d21c29

Please sign in to comment.