Skip to content

Commit e15643f

Browse files
authored
Update Readme.md
1 parent 976aee1 commit e15643f

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

Readme.md

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,13 @@ Run the following commands to see the difference in the image sizes of 2 docker
44
docker build -t app .
55
docker build -t multi_stage -f Dockerfile_with_multi_stage .
66

7-
simple workflow file-
8-
name: My First GitHub Actions
9-
on: [push]
10-
jobs:
11-
action-job:
12-
runs-on: self-hosted
13-
steps:
14-
- uses: actions/checkout@v1
15-
- name: Build and push image
16-
run: |
17-
docker build -t multi_stage -f Dockerfile_with_multi_stage .
18-
197
**On-demand self-hosted AWS EC2 runner for GitHub Actions**
208

219
Use the following steps to prepare your workflow for running on your EC2 self-hosted runner:
22-
1. Prepare IAM user with AWS access keys
10+
1. Create IAM user with AWS access keys
2311
Create an IAM user with the required EC2 roles. To create, go to IAM -> Create user.
24-
25-
12+
![image](https://github.com/shivaniii23/python-multi-stage-github-actions/assets/54891990/3648fa0f-b0e3-45f8-bafd-3c468bead418)
13+
2614
Then click on next -> create.
2715
Then we need to create the access key for this user. Click on the user -> Create access key .
2816

@@ -35,14 +23,17 @@ Go to your repository on GitHub -> settings -> Secrets and variables -> Actions
3523

3624

3725
Add the secret key and access key from the csv we downloaded and the AWS_REGION.(eg - us-east-1).
26+
3827
2. Prepare GitHub personal access token
3928
Create a new GitHub personal access token with the repository scope. The action will use the token for self-hosted runners’ management in the GitHub account on the repository level. Add the token to GitHub secrets.
4029
Go to your GitHub profile on GitHub -> settings -> Developer Settings -> Personal Access Tokens -> Tokens(classic) -> Generate new token -> Generate new token(classic) -> Add note, set expiration date -> Select all the boxes in scope and -> Generate token.
4130
You will get the token. Copy it because it won’t be accessible afterwards.
4231

4332
Now, we will add this token in our GitHub repository that we will use for this project.
33+
We will also add docker hub credentials so that we can push the docker image.
4434
Go to your repository on GitHub -> settings -> Secrets and variables -> Actions -> Secrets -> Repository secrets.
4535

36+
4637
3. Prepare EC2 image
4738
Create a new EC2 instance based on any Linux distribution you need. Select a key-pair and new security group and create the instance.
4839
Connect to the instance using SSH, install docker, then enable docker service –
@@ -57,20 +48,21 @@ Select the instance -> Actions -> Image and templates -> Create image -> Enter t
5748

5849
Check the status of the image and make sure it is in ‘available’ state. Remove the instance if not required anymore.
5950

51+
6052
4. Prepare VPC with subnet and security group
6153
Create a new VPC and a new subnet in it. Or use the existing VPC and subnet. We will use the default VPC.
6254

63-
Create a new security group for the runners in the VPC. Only the outbound traffic on port 443 should be allowed for pulling jobs from GitHub. And inbound traffic on port 22 is required.
55+
Create a new security group for the runners in the VPC. Only the inbound traffic on port 22 is required. Keep the outbound traffic port as it is.
6456

65-
6657

58+
6759
5. Configure the GitHub workflow
6860
Create a new GitHub Actions workflow or edit the existing one. We have a project which creates a docker container with multi stage builds.
69-
Github repository - https://github.com/shivaniii23/python_multi_stage
70-
We have deploy.yml file which has the job named ‘My First GitHub Actions’ which starts the EC2 runner on push, executes the job, and terminates the runner after everything.
61+
Github repository - https://github.com/shivaniii23/python-multi-stage-github-actions.git
62+
We have “deploy.yml” file which has the job named ‘My First GitHub Actions’ which starts the EC2 runner on push, executes the job, and terminates the runner after everything.
63+
Make sure you don’t have a repository on the hub with the same name as this one.
7164

7265

73-
74-
75-
76-
66+
67+
68+
Here, we can see that the docker image was built and pushed to docker hub.

0 commit comments

Comments
 (0)