Last active
March 8, 2024 20:15
-
-
Save leepa/260a7f8765a48db094f5cbf2fb45ea48 to your computer and use it in GitHub Desktop.
A buildspec for CodeBuild... for cross platform building with buildx - enjoy :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This helped me out quite a bit getting buildx to work in codebuild. This was my full command list: