Skip to content

Instantly share code, notes, and snippets.

@leepa
Last active Jun 30, 2022
Embed
What would you like to do?
A buildspec for CodeBuild... for cross platform building with buildx - enjoy :)
version: 0.2
phases:
install:
runtime-versions:
docker: 19
commands:
- docker version
- curl -JLO https://github.com/docker/buildx/releases/download/v0.4.2/buildx-v0.4.2.linux-amd64
- mkdir -p ~/.docker/cli-plugins
- mv buildx-v0.4.2.linux-amd64 ~/.docker/cli-plugins/docker-buildx
- chmod a+rx ~/.docker/cli-plugins/docker-buildx
- docker run --privileged --rm tonistiigi/binfmt --install all
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker buildx create --use --name crossx
- docker buildx build --push --platform=linux/amd64,linux/arm64 -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG .
@rchernobelskiy
Copy link

rchernobelskiy commented Oct 27, 2021

Thanks!

@kapilt
Copy link

kapilt commented Oct 31, 2021

❤️ 👏 💯

i assume that the old version here is due to the ancient docker version in codebuild.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment