Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Cd_buld_push_docker.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything needs to happen within a github action workflow. Check the reference example: https://github.com/data-max-hq/abacus/blob/main/.github/workflows/cicd.yaml

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# .env variables should look like this
#AWS_REGION="<aws-region>"
#AWS_ACCOUNT_ID="<aws-account-id>"
#IMAGE_NAME="<image-name>"
#REPOSITORY_NAME="<repository-name>"
# Load environment variables from .env file
export $(grep -v '^#' .env | xargs)

# Authenticate Docker with AWS ECR
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com

# Build the Docker image
docker build -t $IMAGE_NAME:latest .

# Tag the Docker image
docker tag $IMAGE_NAME:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$REPOSITORY_NAME:latest

# Push the Docker image to ECR
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$REPOSITORY_NAME:latest