Skip to content

Commit aba10da

Browse files
Steps to build application Docker image on EC2
1 parent 7040bef commit aba10da

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
On AWS console:
2+
- Spin up EC2 instance: AMI:Ubuntu latest, instance type: t2.medium
3+
4+
On your machine:
5+
- ssh -i "<your-dot-pem-file>" ubuntu@<your-ec2-instance-dns-name>
6+
7+
On EC2 VM:
8+
- sudo apt-get update -y
9+
- sudo apt-get install ca-certificates curl
10+
- sudo install -m 0755 -d /etc/apt/keyrings
11+
- sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
12+
- sudo chmod a+r /etc/apt/keyrings/docker.asc
13+
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
14+
- sudo apt-get update
15+
- sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
16+
- sudo usermod -a -G docker ${USER}
17+
- exit
18+
19+
On your machine:
20+
- ssh -i "<your-dot-pem-file>" ubuntu@<your-ec2-instance-dns-name>
21+
22+
On EC2 VM:
23+
- sudo apt-get update
24+
- sudo apt-get install apt-transport-https ca-certificates gnupg curl
25+
- curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
26+
- curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
27+
- echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
28+
- sudo apt-get update && sudo apt-get install google-cloud-cli
29+
- gcloud init
30+
- follow the prompts
31+
- configure your gcloud project
32+
- gcloud auth configure-docker
33+
- follow the prompts
34+
- docker run hello-world
35+
- docker tag hello-world:latest gcr.io/<your-project-id>/hello-world:april22-1
36+
- docker images
37+
- docker push gcr.io/<your-project-id>/hello-world:april22-1
38+
- docker images
39+
- exit
40+
41+
On your machine:
42+
- Create tar gz of your assignment4 folder
43+
- tar -cvf assignment4.tar assignment4
44+
- scp -i "<your-dot-pem-file>" assignment4.tar ubuntu@<your-ec2-instance-dns-name>:~/.
45+
- ssh -i "<your-dot-pem-file>" ubuntu@<your-ec2-instance-dns-name>
46+
47+
On EC2 VM:
48+
- tar -xvf assignment4.tar
49+
- cd assignment4
50+
- docker build -t gcr.io/<your-project-id>/greetings:latest .
51+
- docker push gcr.io/<your-project-id>/greetings:latest

CICD/containerized/jenkins_on_gke/cicd-steps.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ You will install Jenkins in your cluster.
5050
- gcloud config set project ${PROJECT_ID}
5151
- If the first creation of project fails, you can use
5252
- gcloud projects create <your-proposed-project-id>
53+
- gcloud auth configure-docker
5354

5455
5) Enable Google cloud billing account and enable Kubernetes Engine API for your project
5556
- https://console.cloud.google.com/billing

0 commit comments

Comments
 (0)