Skip to content

Commit 367aedc

Browse files
committed
added week7 readme
1 parent 3be7b67 commit 367aedc

File tree

3 files changed

+81
-9
lines changed

3 files changed

+81
-9
lines changed

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,28 @@ References
208208
- [Configuring service account](https://dvc.org/doc/user-guide/setup-google-drive-remote)
209209

210210
- [Github actions](https://docs.github.com/en/actions/quickstart)
211+
212+
213+
## Week 7: Container Registry - AWS ECR
214+
215+
<img src="https://img.shields.io/static/v1.svg?style=for-the-badge&label=difficulty&message=medium&color=orange"/>
216+
217+
Refer to the [Blog Post here](https://www.ravirajag.dev/blog/mlops-container-registry)
218+
219+
A container registry is a place to store container images. A container image is a file comprised of multiple layers which can execute applications in a single instance. Hosting all the images in one stored location allows users to commit, identify and pull images when needed.
220+
221+
Amazon Simple Storage Service (S3) is a storage for the internet. It is designed for large-capacity, low-cost storage provision across multiple geographical regions.
222+
223+
In this week, I will be going through the following topics:
224+
225+
- `Basics of S3`
226+
227+
- `Programmatic access to S3`
228+
229+
- `Configuring AWS S3 as remote storage in DVC`
230+
231+
- `Basics of ECR`
232+
233+
- `Configuring GitHub Actions to use S3, ECR`
234+
235+
![Docker](images/ecr_flow.png)

images/ecr_flow.png

439 KB
Loading

week_7_ecr/README.md

+56-9
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,44 @@ python inference.py
6666
python inference_onnx.py
6767
```
6868

69-
### Google Service account
69+
## S3 & ECR
7070

71-
Create service account using the steps mentioned here: [Create service account](https://www.ravirajag.dev/blog/mlops-github-actions)
71+
Follow the instructions mentioned in the [blog post](https://www.ravirajag.dev/blog/mlops-container-registry) for creating S3 bucket and ECR repository.
7272

7373
### Configuring dvc
7474

7575
```
76-
dvc init
77-
dvc remote add -d storage gdrive://19JK5AFbqOBlrFVwDHjTrf9uvQFtS0954
78-
dvc remote modify storage gdrive_use_service_account true
79-
dvc remote modify storage gdrive_service_account_json_file_path creds.json
76+
dvc init (this has to be done at root folder)
77+
dvc remote add -d model-store s3://models-dvc/trained_models/
8078
```
8179

82-
`creds.json` is the file created during service account creation
80+
### AWS credentials
8381

82+
Create the credentials as mentioned in the [blog post](https://www.ravirajag.dev/blog/mlops-container-registry)
83+
84+
**Do not share the secrets with others**
85+
86+
Set the ACCESS key and id values in environment variables.
87+
88+
```
89+
export AWS_ACCESS_KEY_ID=<ACCESS KEY ID>
90+
export AWS_SECRET_ACCESS_KEY=<ACCESS SECRET>
91+
```
92+
93+
### Trained model in DVC
94+
95+
Sdd the trained model(onnx) to dvc using the following command:
96+
97+
```shell
98+
cd dvcfiles
99+
dvc add ../models/model.onnx --file trained_model.dvc
100+
```
101+
102+
Push the model to remote storage
103+
104+
```shell
105+
dvc push trained_model.dvc
106+
```
84107

85108
### Docker
86109

@@ -89,13 +112,13 @@ Install the docker using the [instructions here](https://docs.docker.com/engine/
89112
Build the image using the command
90113

91114
```shell
92-
docker build -t inference:latest .
115+
docker build -t mlops-basics:latest .
93116
```
94117

95118
Then run the container using the command
96119

97120
```shell
98-
docker run -p 8000:8000 --name inference_container inference:latest
121+
docker run -p 8000:8000 --name inference_container mlops-basics:latest
99122
```
100123

101124
(or)
@@ -106,6 +129,30 @@ Build and run the container using the command
106129
docker-compose up
107130
```
108131

132+
### Pushing the image to ECR
133+
134+
Follow the instructions mentioned in [blog post](https://www.ravirajag.dev/blog/mlops-container-registry) for creating ECR repository.
135+
136+
- Authenticating docker client to ECR
137+
138+
```
139+
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 246113150184.dkr.ecr.us-west-2.amazonaws.com
140+
```
141+
142+
- Tagging the image
143+
144+
```
145+
docker tag mlops-basics:latest 246113150184.dkr.ecr.us-west-2.amazonaws.com/mlops-basics:latest
146+
```
147+
148+
- Pushing the image
149+
150+
```
151+
docker push 246113150184.dkr.ecr.us-west-2.amazonaws.com/mlops-basics:latest
152+
```
153+
154+
Refer to `.github/workflows/build_docker_image.yaml` file for automatically creating the docker image with trained model and pushing it to ECR.
155+
109156

110157
### Running notebooks
111158

0 commit comments

Comments
 (0)