Skip to content

Instantly share code, notes, and snippets.

@shadyonline
Forked from leepa/buildspec.yml
Created January 18, 2022 16:08
Show Gist options
  • Save shadyonline/0c012946d60bfabe8ed559f4a152a8b7 to your computer and use it in GitHub Desktop.
Save shadyonline/0c012946d60bfabe8ed559f4a152a8b7 to your computer and use it in GitHub Desktop.
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 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment