Skip to content

fix: Fix building the STK docker images with latest docker which uses Bake - #821

Merged
duposyl merged 8 commits into
mainfrom
fix/docker-building-with-bake
Sep 10, 2025
Merged

duposyl merged 8 commits into
mainfrom
fix/docker-building-with-bake

Conversation

@duposyl

@duposyl duposyl commented Sep 6, 2025

Copy link
Copy Markdown
Contributor

Latest versions of Docker promoted Bake as the default build tool for Compose (release notes). Bake tries to build the images in parallel which fails with the error below. Added additional_contexts declarations to the STK Ubuntu Docker compose file to declare the dependencies between the various images, hence defining the build order. See the Use another service's image as the base image section in the Docker Compose documentation.

Also fixed a few minor FromAsCasing docker warnings, and installed more dependencies as part of building the STK container images with tox to allow to follow the steps in CONTRIBUTING.md to run the doc_snippets_tests initialisation tests which require grpc.

------
 > [stk-python3_13 internal] load metadata for docker.io/ansys/stk-12.10:dev-ubuntu22.04:
------
Dockerfile:3

--------------------

   1 |     # By default, start from the base STK Engine image

   2 |     ARG baseImage=ansys/stk-12.10:dev-ubuntu22.04

   3 | >>> FROM ${baseImage}

   4 |

   5 |     # Install system dependencies

--------------------

target stk-pybase: failed to solve: ansys/stk-12.10:dev-ubuntu22.04:
failed to resolve source metadata for docker.io/ansys/stk-12.10:dev-ubuntu22.04:
pull access denied, repository does not exist or may require authorization: server message:
insufficient_scope: authorization failed

Fixes docker warning below in the various dockerfiles.

#2 WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 4)
This allows to run the doc_snippets_tests as they require grpc.
@duposyl
duposyl requested a review from a team as a code owner September 6, 2025 20:56
@github-actions github-actions Bot added fix Pull requests related to resolving problems or errors docker Docker maintenance related labels Sep 6, 2025
@duposyl duposyl changed the title Fix building the STK docker images with latest docker which uses Bake fix: Fix building the STK docker images with latest docker which uses Bake Sep 6, 2025
@duposyl duposyl added the maintenance Generic maintenance related label Sep 6, 2025
@codecov-commenter

codecov-commenter commented Sep 6, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.70%. Comparing base (d009ff0) to head (3962d5e).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #821      +/-   ##
==========================================
- Coverage   89.70%   89.70%   -0.01%     
==========================================
  Files          67       67              
  Lines      188022   188022              
  Branches     1339     1339              
==========================================
- Hits       168664   168662       -2     
- Misses      18965    18967       +2     
  Partials      393      393              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@duposyl duposyl removed the maintenance Generic maintenance related label Sep 7, 2025

@jorgepiloto jorgepiloto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding this, @duposyl. If we are moving to bake, should we also update the commands in tox.ini to use docker buildx bake rather than docker compose?

The arguments and options should remain the same, only thing changing is the command.

@jorgepiloto

Copy link
Copy Markdown
Member

It looks like as long as we set:

DOCKER_BUILDKIT=1

we can keep using docker compose and it will understand the additional_context blocks.

@duposyl

duposyl commented Sep 8, 2025

Copy link
Copy Markdown
Contributor Author

@jorgepiloto, is your concern that after this change docker compose with version prior to 2.36.2 would no longer work? Is that something that you are able to test on your side (mine is now Docker Compose version v2.39.2-desktop.1)?

@duposyl

duposyl commented Sep 9, 2025

Copy link
Copy Markdown
Contributor Author

@jwinkle8 tried this change with Docker Compose version v2.29.7-desktop.1, which is still using the old docker compose builder (as the switch to Bake was in 2.36.2). That failed because of the new additional_contexts lines in docker-compose.yml. We could not find a way to get the same docker-compose.yml to build successfully with v2.29.7 and v2.39.2. We tried DOCKER_BUILDKIT=1 and a few other things to no avail.

Therefore, it looks like we have the following options:

  1. Move forward with this change and require docker compose >= 2.36.2.
  2. For now stick with the old versions of docker compose < 2.36.2 and keep what we had before this change. I will rollback my local install to an older version.
  3. Set the COMPOSE_BAKE=false environment variable so the latest versions keep using the old builder.
    • This works but generates a warning:
      time="2025-09-09T02:39:00-04:00" level=warning msg="COMPOSE_BAKE=false is deprecated, support for internal compose builder will be removed in next release"
    • This buys us some time but we will need to address this later on.
  4. Add a new script that explicitly builds the images in the right order by splitting the docker compose calls to:
    docker compose build stk
    docker compose build stk-pybase
    docker compose build
    

@jorgepiloto, can you think of any other option? Should we go with option 3 for now?

@jorgepiloto

Copy link
Copy Markdown
Member

Thanks for listing these, @duposyl. If it works for you, let's go with the first option and be up to date as soon as possible.

@github-actions github-actions Bot added the docs Issues related to documentation label Sep 10, 2025
@duposyl

duposyl commented Sep 10, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for listing these, @duposyl. If it works for you, let's go with the first option and be up to date as soon as possible.

@jorgepiloto: Sounds good. I have added a note to the documentation in 9fdc166. It looks like this:

image

Only question left on my side is regarding the GitHub runner. There is no concern with getting the latest Docker Compose on it, right? If that's not a concern, then this PR is good to go as far as I am concerned. Thanks!

@jorgepiloto

Copy link
Copy Markdown
Member

Perfect, thanks @duposyl. I will update the self-hosted runner to use the latest stable version of Docker and Docker Compose.

@duposyl
duposyl enabled auto-merge (squash) September 10, 2025 11:53
@duposyl
duposyl merged commit 7d06738 into main Sep 10, 2025
@duposyl
duposyl deleted the fix/docker-building-with-bake branch September 10, 2025 12:56
duposyl added a commit that referenced this pull request Dec 5, 2025
… Bake (#821)

(cherry-picked 7d06738)

Co-Authored-By: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
Co-Authored-By: Jorge Martínez <28702884+jorgepiloto@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Docker maintenance related docs Issues related to documentation fix Pull requests related to resolving problems or errors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants