From 28aaf6cb9e5fc18609b6b518fb7eeb087aa6a150 Mon Sep 17 00:00:00 2001 From: Schneems Date: Mon, 29 Apr 2024 12:56:03 -0500 Subject: [PATCH] Prefer setting platform via env var --- test/fixtures/cnb/ruby/image_structure.md | 4 ++-- test/fixtures/cnb/ruby/multiple_langs.md | 9 +++++---- test/fixtures/cnb/shared/configure_builder.md | 10 ++++++++++ test/fixtures/cnb/shared/use_the_image.md | 6 +++--- test/fixtures/cnb/shared/what_is_a_builder.md | 9 --------- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/test/fixtures/cnb/ruby/image_structure.md b/test/fixtures/cnb/ruby/image_structure.md index acffc43..760c3db 100644 --- a/test/fixtures/cnb/ruby/image_structure.md +++ b/test/fixtures/cnb/ruby/image_structure.md @@ -8,13 +8,13 @@ If you’re an advanced `Dockerfile` user you might be interested in learning mo If you view the root directory `/` you’ll see there is a `layers` folder. Every buildpack that executes gets a unique folder. For example: ``` -:::>> $ docker run --rm --platform linux/amd64 my-image-name "ls /layers | grep ruby" +:::>> $ docker run --rm my-image-name "ls /layers | grep ruby" ``` Individual buildpacks can compose multiple layers from their buildpack directory. For example you can see that `ruby` binary is present within that ruby buildpack directory: ``` -:::>> $ docker run --rm --platform linux/amd64 my-image-name "which ruby" +:::>> $ docker run --rm my-image-name "which ruby" ``` OCI images are represented as sequential modifications to disk. By scoping buildpack disk modifications to their own directory, the CNB API guarantees that changes to a layer in one buildpack will not affect the contents of disk to another layer. This means that OCI images produced by CNBs are rebaseable by default, while those produced by Dockerfile are not. diff --git a/test/fixtures/cnb/ruby/multiple_langs.md b/test/fixtures/cnb/ruby/multiple_langs.md index 7066d39..07fb7bc 100644 --- a/test/fixtures/cnb/ruby/multiple_langs.md +++ b/test/fixtures/cnb/ruby/multiple_langs.md @@ -31,12 +31,13 @@ Ensure that a `requirements.txt` file, a `package.json` file and a `Gemfile.lock ``` :::>> $ touch requirements.txt -:::>> $ pack build multiple-languages-app --path . +:::>> $ pack build my-image-name --path . ``` -You can run the image and inspect the dependencies: +You can run the image and inspect everything is installed as expected: ``` -$ docker run -it --rm --platform linux/amd64 multiple-languages-app bash -:::>- $ docker run --rm --platform linux/amd64 multiple-languages-app python --version +$ docker run -it --rm my-image-name bash +$ which python +:::-> $ docker run --rm my-image-name "which python" ``` diff --git a/test/fixtures/cnb/shared/configure_builder.md b/test/fixtures/cnb/shared/configure_builder.md index fd8d872..160bab6 100644 --- a/test/fixtures/cnb/shared/configure_builder.md +++ b/test/fixtures/cnb/shared/configure_builder.md @@ -11,3 +11,13 @@ You can view your default builder at any time: ``` :::>> $ pack config default-builder ``` + +The following tutorial is built on amd64 architecture (also known as x86). If you are building on a machine with different architecture (such as arm64/aarch64 for a mac) you will need to tell Docker to use `linux/amd64` architecture. You can do this via a `--platform linux/amd64` flag or by exporting an environment variable: + +``` +$ export DOCKER_DEFAULT_PLATFORM=linux/amd64 +:::-- rundoc.configure +# Needed because all `$` commands are run as separate isolated processes + +ENV["DOCKER_DEFAULT_PLATFORM"] = "linux/amd64" +``` diff --git a/test/fixtures/cnb/shared/use_the_image.md b/test/fixtures/cnb/shared/use_the_image.md index e591eaa..295f7f6 100644 --- a/test/fixtures/cnb/shared/use_the_image.md +++ b/test/fixtures/cnb/shared/use_the_image.md @@ -5,8 +5,8 @@ Even though we used `pack` and CNBs to build our image, it can be run with your By default, images will be booted into a web server configuration. You can launch the app we just built by running: ``` -$ docker run -it --rm --platform linux/amd64 --env PORT=9292 -p 9292:9292 my-image-name -:::-> background.start("docker run --rm --platform linux/amd64 --env PORT=9292 -p 9292:9292 my-image-name", name: "docker_server") +$ docker run -it --rm --env PORT=9292 -p 9292:9292 my-image-name +:::-> background.start("docker run --rm --env PORT=9292 -p 9292:9292 my-image-name", name: "docker_server") :::-- $ sleep 10 :::-> background.log.read(name: "docker_server") ``` @@ -46,7 +46,7 @@ Now you can inspect the container interactively. For example, you can see the fi ``` $ ls -:::-> $ docker run --rm --platform linux/amd64 my-image-name ls +:::-> $ docker run --rm my-image-name ls ``` And anything else you would typically do via an interactive container session. diff --git a/test/fixtures/cnb/shared/what_is_a_builder.md b/test/fixtures/cnb/shared/what_is_a_builder.md index 662f79d..6182584 100644 --- a/test/fixtures/cnb/shared/what_is_a_builder.md +++ b/test/fixtures/cnb/shared/what_is_a_builder.md @@ -16,12 +16,3 @@ You can view the contents of a builder via the command `pack builder inspect`. F > Your output version numbers may differ. This output shows the various buildpacks that represent the different languages that are supported by this builder such as `heroku/go` and `heroku/nodejs-engine`. - - -