Skip to content

Commit

Permalink
Prefer setting platform via env var
Browse files Browse the repository at this point in the history
  • Loading branch information
schneems committed Apr 29, 2024
1 parent 688c1ae commit 28aaf6c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions test/fixtures/cnb/ruby/image_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 5 additions & 4 deletions test/fixtures/cnb/ruby/multiple_langs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```
10 changes: 10 additions & 0 deletions test/fixtures/cnb/shared/configure_builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```
6 changes: 3 additions & 3 deletions test/fixtures/cnb/shared/use_the_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
```
Expand Down Expand Up @@ -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.
9 changes: 0 additions & 9 deletions test/fixtures/cnb/shared/what_is_a_builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.


<!--
Debug: Output the SHA of the builder:
```
:::>> $ docker inspect --format='{{index .RepoDigests 0}}' heroku/builder:22
```
-->

0 comments on commit 28aaf6c

Please sign in to comment.