Tips on how to push a number of Dockerfile apps to AWS ECR on the identical time

0
9
Adv1


Adv2

I’ve a mother or father listing containing a number of sub-directories. Every of those baby directories is a distinct utility and comprises a Dockerfile.

I need to construct and push every picture to AWS ECR.

The listing appears to be like as follows:

├── apps
    ├── microservice1
        ├── app.js
        ├── Dockerfile
        ├── bundle.json
        └── readiness.txt
    ├── frontend
        ├── Dockerfile
        ├── index.html
        ├── bundle.json
        ├── server.js
    ├── microservice2
        ├── app.py
        ├── bootstrap.sh
        ├── Dockerfile
        └── necessities.txt

Discover there are 3 apps, every with their very own Dockerfile, below the mother or father apps listing.

Within the beneath code snippet, now we have already set AWS_REGION to our desired area title.

When you’ve got not carried out this, run export AWS_REGION='eu-west-1', or acceptable.

Additionally set the ACCOUNT_ID to your AWS’s account ID.

aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
PROJECT_NAME=our-project-name
export APP_VERSION=1.0
for app in microservice1 microservice2 frontend; do
  aws ecr describe-repositories --repository-name $PROJECT_NAME/$app >/dev/null 2>&1 || 
  aws ecr create-repository --repository-name $PROJECT_NAME/$app >/dev/null
  TARGET=$ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$PROJECT_NAME/$app:$APP_VERSION
  docker construct -t $TARGET apps/$app
  docker push $TARGET
carried out

Notice how we use the for loop on line 4 above to loop via our listing names inside the apps mother or father listing.

Adv3