DEV Community

Cover image for Build and Push wordpress project to AWS ECR
Salman Sohail
Salman Sohail

Posted on • Originally published at salzam.com on

Build and Push wordpress project to AWS ECR

This article is the continuation of WordPress with Docker, AWS (ECS, Code Pipeline, Load Balancer, RDS, EFS) Complete Series. For better understating, please start from the beginning of the series.

Build and Tag WordPress Docker project

As we have already set up our WordPress Docker project in Dockerize WordPress with themes, plugins and common configuration article. Its time to Tag and push our WordPress project to AWS ECR.

You can also download the Docker WordPress project used in this tutorial series from https://github.com/saluminati/personal-docker-blog

Go to you wordpress project root directory and execute the following commands:


docker build .

You should see something like that on the console

Now we need to tag the build, for that, please run the following command:


docker images


# for you: replace --image-- with your image_id
# replace salman-docker-blog with the name your prefer

docker tag --image-- salman-docker-blog:v0.0.1

Run docker images command and you should see your image tagged properly

Push the Docker build to ECR

Please follow this link to install AWS cli on your local machine.

Once its installed, you should be able to run the following command on your console to configure AWS IAM User credentials you have recently downloaded as a CSV file.

aws configure

Please use the credentials from the CSV file you have downloaded in Create IAM (User, Roles and Policies) article.

It will ask for AWS Key ID, Secret Key and AWS region. Please use the appropriate region.

More information about AWS regions are available here

Create ECR Repository

In this section, we will create a ECR repository on AWS and push our docker build by using AWS cli.

Letโ€™s do this !

Go to AWS service tab and search ECR. Click on create repository.

Make sure you enable Tag Immutability.

Copy the repository URI, we will use it in the next step.

Push to AWS ECR !

Finally !!!! we are now ready to push our Docker build to Amazon AWS

Go to your console and run the following commands:

docker build . -t salman-docker-blog

docker tag salman-docker-blog:latest <repouri>:v1.0.0</repouri>

Please replace the with your ECR repository you have created earlier.

Now your docker image is tagged, time to push it. For that, you will need to run the following command on console to login to AWS ECR service.

aws ecr get-login --no-include-email

This command will print a long string on your console screen. Please copy that long string and paste it to your console again. That will log you in to ECR Service. Once you paste the code and hit enter, you should be able to see Login Succeeded message.

Now to final command

docker push <repouri>:v1.0.0</repouri>

When you will click on your repository in AWS ECR. You will be able to see that version 1.0.0 is being pushed.

Previous

Create AWS EFS (Elastic File System) Plugin storage for WordPress behind Load Balancer

Next

Create Load Balancer for WordPress website

Top comments (0)