-
Notifications
You must be signed in to change notification settings - Fork 10k
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
added docker-multi-stage builds #10832
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also fix coding style as reported by editorconfig workflow
.devops/cuda.Dockerfile
Outdated
find build -name "*.so" -exec cp {} /app/lib \; | ||
|
||
|
||
FROM ${BASE_CUDA_DEV_CONTAINER} AS full |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's safe to switch the image ro runtime here, as we don't gonna build anything from this point on
FROM ${BASE_CUDA_DEV_CONTAINER} AS full | |
FROM ${BASE_CUDA_RUN_CONTAINER} AS full |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if that is so, it is safe to not install cmake or any other build packages?
This will make the image and build time smaller by a tiny bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the runtime doesn't need to have cmake and build-essentials
.devops/musa.Dockerfile
Outdated
find build -name "*.so" -exec cp {} /app/lib \; | ||
|
||
|
||
FROM ${BASE_MUSA_DEV_CONTAINER} AS full |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
.github/workflows/docker.yml
Outdated
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
push: true | ||
platforms: ${{ matrix.config.platforms }} | ||
# tag list is generated from step above | ||
tags: ${{ steps.tag.outputs.output_tags }} | ||
tags: full-${{ steps.tag.outputs.output_tags }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the old full
tag become full-cpu
? If yes, this will be a breaking change for downstream projects, I don't think we should let that happen, because the full
tag will not be deleted people using it in an automated way won't receive any updates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue is that "full" only tag came without any specification, and we have many types of builds for given targets, the possible workaround will be a hack but I think it's doable.
We have the cuda, rocm, intel, vulkan but cpu has no spec, it was just full, when you do multi-stage with the current tag system it is a bit tricky, but I will give it a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should keep the tag as-is, because many people depends on that and we currently don't have a way to communicate with them about breaking changes in tag name.
changing full
, light
and especially server
to something else will make someone already using it never receive updates in the future. and worst, because there is no error or warning when they run it, they wouldn't know there is a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ngxson the tags are as-is, just a little issue of caching layers, it's going to be a few more pushes, sorry.
bfdf494
to
72d0847
Compare
@ngxson I am really sorry about the spam, starting to use act. |
72d0847
to
eee1ea4
Compare
@ngxson ok figured out the cache, it will be using github cache, still a bit experimental but it works best at this point in time. In the dockerfiles there is a
can this be changed to a mv? It would same some space. Or I can just copy this from the cpu dockerfile
instead of copying the full /app in the full versions. |
libcurl4-openssl-dev \ | ||
libgomp1 | ||
|
||
COPY requirements.txt requirements.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COPY requirements.txt requirements.txt | |
COPY requirements.txt . |
echo "output_tags=$TAGS" >> $GITHUB_OUTPUT | ||
echo "output_tags=$TAGS" # print out for debugging | ||
if [[ "${{ matrix.config.tag }}" == "cpu" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering, can we do this a bit more simple by using sed
to remove -cpu
from tag name? so we don't have to specify FULLTAGS
, LIGHTTAGS
, SERVERTAGS
Another approach (with less code) could be:
BASE_IMAGE="ghcr.io/${REPO_OWNER}/${REPO_NAME}"
FULLTAGS="${BASE_IMAGE}:full,${BASE_IMAGE}:full-cpu"
SERVERTAGS="${BASE_IMAGE}:server,${BASE_IMAGE}:server-cpu"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could try something with sed, like:
echo '${{ matrix.config.tag }}' | sed 's/-cpu//g'
It would remove the if statement, but in my opinion the if statement is more "readable" or expressive at first glance.
I can simplify this, still I would need at least 3 vars to make this work and keep the project tags has they are.
The PREFIX, POSTFIX and one extra TYPE for the "matrix tag"
if [[ "${{ matrix.config.tag }}" == "cpu" ]]; then
TYPE=""
else
TYPE="-${{ matrix.config.tag }}"
fi
PREFIX="ghcr.io/${REPO_OWNER}/${REPO_NAME}:"
POSTFIX="-${TAG_POSTFIX}"
And
echo "prefix=$PREFIX" >> $GITHUB_OUTPUT
echo "type=$TYPE" >> $GITHUB_OUTPUT
echo "postfix=$POSTFIX" >> $GITHUB_OUTPUT
with in each build-push-action for the there it would be
tags: ${{ steps.tag.outputs.prefix }}full${{ steps.tag.outputs.type }},${{ steps.tag.outputs.output_tags }}full${{ steps.tag.outputs.type }}${{ steps.tag.outputs.postfix }}
Or
FULLTAGS="${PREFIX}full${TYPE},${PREFIX}full${TYPE}${POSTFIX}"
LIGHTTAGS="${PREFIX}light${TYPE},${PREFIX}light${TYPEl${POSTFIX}"
SERVERTAGS="${PREFIX}server${TYPE},${PREFIX}server${TYPE}${POSTFIX}"
echo "full_output_tags=$FULLTAGS" >> $GITHUB_OUTPUT
echo "light_output_tags=$LIGHTTAGS" >> $GITHUB_OUTPUT
echo "server_output_tags=$SERVERTAGS" >> $GITHUB_OUTPUT
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed new code, normalized all docker images, hopefully optimized docker layers.
Yes I think we can, I don't see any problem with this as we never run I'll test on cpu + CUDA in the next few days when I come back from vacation |
Yes, I don't see why the |
@slaren agree, but I would be happy to know what do I need to copy for the full image to work instead of the complete /app folder just to try and keep these images has small has possible for now. From what I can tell it's the python scripts, the .so and the build/bin. |
I already tried to copy as little as possible for the full image in the |
735b9b0
to
bf1caab
Compare
I normalized all docker images, improved the code a bit, I think everything is ok. |
bf1caab
to
9de4023
Compare
It's pushing multiple untaged images, checking. |
9de4023
to
435bce0
Compare
Fixed, added provenance to build-and-push. |
Added multi-stage dockerfile builds, improved total build time to under 2 hours, added Vulkan and Full-intel.
Updated rocm dockerfile.
Hopefully it will all work without any problems.