diff --git a/docs/content/build-image.md b/docs/content/build-image.md index b0040f9b8..a7fa123af 100644 --- a/docs/content/build-image.md +++ b/docs/content/build-image.md @@ -80,7 +80,7 @@ actions: description: World 2.0 /Users/sigje/.porter/mixins/exec/exec build --debug -FROM debian:stretch +FROM --platform=linux/amd64 debian:stretch-slim ARG BUNDLE_DIR @@ -97,7 +97,7 @@ WORKDIR ${BUNDLE_DIR} CMD ["/cnab/app/run"] Writing Dockerfile =======> -FROM debian:stretch +FROM --platform=linux/amd64 debian:stretch-slim ARG BUNDLE_DIR @@ -114,7 +114,7 @@ WORKDIR ${BUNDLE_DIR} CMD ["/cnab/app/run"] Starting Invocation Image Build =======> -Step 1/9 : FROM debian:stretch +Step 1/9 : FROM --platform=linux/amd64 debian:stretch-slim ---> 5738956efb6b Step 2/9 : ARG BUNDLE_DIR ---> Using cache @@ -208,7 +208,7 @@ After copying any mixins to the .cnab directory, a Dockerfile is generated: ```console Generating Dockerfile =======> -FROM debian:stretch +FROM --platform=linux/amd64 debian:stretch ARG BUNDLE_DIR @@ -225,13 +225,13 @@ WORKDIR ${BUNDLE_DIR} CMD ["/cnab/app/run"] ``` -Porter starts the Dockerfile by using a base image. You can customize the base image by specifying a Dockerfile template in the porter.yaml. Next, a set of CA certificates is added. Next, contents of the current directory are copied into the bundle directory (/cnab/app) in the invocation image. This will include any contributions from the mixin executables. Finally, an entry point that conforms to the CNAB specification is added to the image. +Porter starts the [Dockerfile](/bundle/custom-dockerfile) by using a base image. You can customize the base image by specifying a Dockerfile template in the porter.yaml. By default, Porter only targets a single os/architecture(linux/amd64) for invocation image. If you want to use other platform, feel free to change the platform flag in the generated Dockerfile template. Next, a set of CA certificates is added. Next, contents of the current directory are copied into the bundle directory (/cnab/app) in the invocation image. This will include any contributions from the mixin executables. Finally, an entry point that conforms to the CNAB specification is added to the image. Once this is completed, the image is built: ```console Starting Invocation Image Build =======> -Step 1/9 : FROM debian:stretch +Step 1/9 : FROM --platform=linux/amd64 debian:stretch ---> 5c43e435cc11 Step 2/9 : ARG BUNDLE_DIR ---> Using cache @@ -306,7 +306,7 @@ Copying mixins ===> Copying mixin helm ===> Generating Dockerfile =======> -FROM debian:stretch +FROM --platform=linux/amd64 debian:stretch-slim ARG BUNDLE_DIR diff --git a/docs/content/bundle/custom-dockerfile.md b/docs/content/bundle/custom-dockerfile.md index 27a648386..b68acd94d 100644 --- a/docs/content/bundle/custom-dockerfile.md +++ b/docs/content/bundle/custom-dockerfile.md @@ -24,7 +24,7 @@ When you run porter create, a template Dockerfile is created for you in the curr # You can control where the mixin's Dockerfile lines are inserted into this file by moving the "# PORTER_*" tokens # another location in this file. If you remove a token, its content is appended to the end of the Dockerfile. -FROM debian:stretch-slim +FROM --platform=linux/amd64 debian:stretch-slim # PORTER_INIT @@ -47,6 +47,8 @@ dockerfile: template.Dockerfile It is your responsibility to provide a suitable base image, for example one that has root ssl certificates installed. *You must use a base image that is debian-based, such as debian or ubuntu with apt installed.* Mixins assume that apt is available to install packages. +Porter only supports targeting a single os/architecture when the bundle is built. By default, Porter targets linux/amd64. +You can change the platform used in the Dockerfile. # Buildkit diff --git a/pkg/build/testdata/buildkit.Dockerfile b/pkg/build/testdata/buildkit.Dockerfile index d070426ff..c68e2d31e 100644 --- a/pkg/build/testdata/buildkit.Dockerfile +++ b/pkg/build/testdata/buildkit.Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile-upstream:1.4.0 -FROM debian:stretch-slim +FROM --platform=linux/amd64 debian:stretch-slim ARG BUNDLE_DIR ARG BUNDLE_UID=65532 diff --git a/pkg/templates/templates/build/buildkit.Dockerfile b/pkg/templates/templates/build/buildkit.Dockerfile index 9fc4ed386..32f438714 100644 --- a/pkg/templates/templates/build/buildkit.Dockerfile +++ b/pkg/templates/templates/build/buildkit.Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile-upstream:1.4.0 -FROM debian:stretch-slim +FROM --platform=linux/amd64 debian:stretch-slim # PORTER_INIT diff --git a/pkg/templates/templates/create/template.buildkit.Dockerfile b/pkg/templates/templates/create/template.buildkit.Dockerfile index 0c1c78197..aba2855f6 100644 --- a/pkg/templates/templates/create/template.buildkit.Dockerfile +++ b/pkg/templates/templates/create/template.buildkit.Dockerfile @@ -10,7 +10,9 @@ # You can control where the mixin's Dockerfile lines are inserted into this file by moving the "# PORTER_*" tokens # another location in this file. If you remove a token, its content is appended to the end of the Dockerfile. -FROM debian:stretch-slim + +# Porter targets linux/amd64 by default. Change the --platform flag to target a different platform +FROM --platform=linux/amd64 debian:stretch-slim # PORTER_INIT diff --git a/pkg/templates/templates_test.go b/pkg/templates/templates_test.go index 1996033e2..ce138c125 100644 --- a/pkg/templates/templates_test.go +++ b/pkg/templates/templates_test.go @@ -39,7 +39,21 @@ func TestTemplates_GetDockerfile(t *testing.T) { gotTmpl, err := tmpl.GetDockerfile() require.NoError(t, err) - test.CompareGoldenFile(t, "./templates/build/buildkit.Dockerfile", string(gotTmpl)) + strTmpl := string(gotTmpl) + require.Contains(t, strTmpl, "--platform=linux/amd64", "missing default platform flag") + test.CompareGoldenFile(t, "./templates/build/buildkit.Dockerfile", strTmpl) +} + +func TestTemplates_GetDockerfileTemplate(t *testing.T) { + c := config.NewTestConfig(t) + tmpl := NewTemplates(c.Config) + + gotTmpl, err := tmpl.GetDockerfileTemplate() + require.NoError(t, err) + + strTmpl := string(gotTmpl) + require.Contains(t, strTmpl, "--platform=linux/amd64", "missing default platform flag") + test.CompareGoldenFile(t, "./templates/create/template.buildkit.Dockerfile", strTmpl) } func TestTemplates_GetCredentialSetJSON(t *testing.T) {