Skip to content

Latest commit

 

History

History
60 lines (51 loc) · 3.58 KB

PUBLISHING.md

File metadata and controls

60 lines (51 loc) · 3.58 KB

Publishing

This repository uses buildx to build and publish the docker image. At time of writing, multi-architectural builds with buildx is an experimental feature. You'd need to enable the experimental features for docker.

To enable experimental features on Windows Docker Desktop:

  1. Right click on the docker icon on the bottom right tray.
  2. Click on Settings. Settings Context Menu
  3. Click on the Enable Experimental Features switch under the Command Line tab.
  4. Command Line Experimental Features Switch
  5. Click Apply and Restart.

Now to build a docker image, we'll use the new docker command line tool called buildx.

  1. Navigate to where you Dockerfile resides.
    cd <PathToDockerFileDirectory>
  2. You need to create your custom builder, and use it. You can't use the default docker builder as it doesn't support multi-architectural builds.
    docker buildx create --name <YourBuilderName>
    docker buildx use <YourBuilderName>
  3. Login to your docker image repository. This will prompt you for your username and password if you haven't logged in before.
    docker login
  4. Now to do the actual build using buildx. For the most part, buildx is just an extension to the build command, meaning it has the same syntax, just a few extended flags and features, such as --platform which we can use for multi-architectural builds.
    docker buildx build --platform <SupportedCpuArchitectures> -t "<YourDockerUserName>/<YourImageName>:<tag>" --push .

    The <SupportedCpuArchitectures> is a string of CPU architectures to support, delimited by comma (e.g. linux/amd64,linux/arm/v6,linux/arm64/v8). The CPU architectures that can be supported depends on:

    1. The base image you're using in the Dockerfile. It must support the architecture you've provided. You can check what CPU architecture your base image supports through finding the image in DockerHub, click on the image, and then click on the Tags tab. There, you'd be able to see a list of OS/Arch it supports. Your list of supported CPU architectures must be a subset of that list. Searching the Supported Architecture for Docker Image
    2. The architecture that's supported by your installed software & architecture. You can find what is supported through running the below command:
      docker buildx inspect --bootstrap

Here's an example with putting everything together:

cd shinobi
docker buildx create --name shinobibuilder
docker buildx use shinobibuilder
docker login
docker buildx build --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 -t mtran0011/shinobi --push .

If you'd like to remove your custom builder, you can use:

docker buildx use default
docker buildx rm shinobibuilder

For more information, see: