#10:GitLab CI Build and Push Docker Image to AWS ECR | GitLab CI CD Docker AWS | Push Image to ECR



In this Video we are going to cover GitLab CI Build and Push Docker Image to AWS ECR | GitLab CI CD Docker AWS | Push Image to ECR
#gitlabcicddockeraws #gitlabcicd #pushimagetoecr
0:00 Introduction
5:00 GitLab CI Build and Push Docker Image to AWS ECR

Please find below Gitlab-ci.yml to GitLab CI Build and Push Docker Image to AWS ECR

variables:
DOCKER_REGISTRY: 908198849120.dkr.ecr.ap-south-1.amazonaws.com
APP_NAME: mavenapp
TAG: “$CI_COMMIT_SHORT_SHA-$CI_PIPELINE_ID”

stages:
– build
– build-docker-image
– push-image-to-aws-ecr

build-java-project:
stage: build
script:
mvn package
artifacts:
paths:
– /home/gitlab-runner/

build-docker-image:
stage: build-docker-image
script:
– docker info
– docker build -t $DOCKER_REGISTRY/$APP_NAME:”$TAG” .

Push Docker Image to AWS ECR:
stage: push-image-to-aws-ecr
image:
name: $DOCKER_REGISTRY/$APP_NAME:”$TAG”
services:
– docker:dind
script:
– aws ecr get-login-password –region ap-south-1 | docker login –username AWS –password-stdin $DOCKER_REGISTRY
– docker tag $DOCKER_REGISTRY/$APP_NAME:”$TAG” $DOCKER_REGISTRY/$APP_NAME:”$TAG”
– docker push $DOCKER_REGISTRY/$APP_NAME:”$TAG”

source

4 thoughts on “#10:GitLab CI Build and Push Docker Image to AWS ECR | GitLab CI CD Docker AWS | Push Image to ECR”
  1. mvn package
    /bin/bash: line 126: mvn: command not found
    Cleaning up project directory and file based variables
    00:00
    ERROR: Job failed: exit code 1

Leave a Reply

Your email address will not be published.

Captcha loading...