diff --git a/buildspec.yml b/buildspec.yml new file mode 100644 index 0000000000..e28c343070 --- /dev/null +++ b/buildspec.yml @@ -0,0 +1,24 @@ +version: 0.2 + +phases: + + pre_build: + commands: + - echo "Logging into Amazon ECR" + - aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin 452499883540.dkr.ecr.$AWS_REGION.amazonaws.com + - echo "Logging into DockerHub" + - docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD + + build: + commands: + - echo "init submodules to add to git config" + - git submodule init + + - echo "Configure submodule to pull with http" + - git config submodule.plugins/pushd-dither.url "https://github.com/pushd/pushd-dither.git" + + - echo "Fetch submodule source" + - git submodule update + + - echo "Building imgproxy started on $(date)" + - ./pushd_build.sh diff --git a/pushd_build.sh b/pushd_build.sh index 492d40975e..93eb597b6a 100755 --- a/pushd_build.sh +++ b/pushd_build.sh @@ -1,5 +1,10 @@ #!/bin/bash -xe # This script is for building and pushing to pushd ECR docker repo. +# # get aws account id from sts if not set +if [[ "${AWS_ACCOUNT_ID}x" == "x" ]]; then + AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) +fi + docker buildx build --platform linux/amd64 -t $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/pushd/imgproxy:$(git rev-parse HEAD) -f docker/Dockerfile . -docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/pushd/imgproxy:$(git rev-parse HEAD) \ No newline at end of file +docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/pushd/imgproxy:$(git rev-parse HEAD)