Skip to content

Commit cf046b4

Browse files
committed
adding cd workflow, updating docker compose, main readme and dev dockerfile
1 parent da3bca1 commit cf046b4

File tree

6 files changed

+53
-7
lines changed

6 files changed

+53
-7
lines changed

.github/workflows/docker.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
docker:
8+
runs-on: ubuntu-latest
9+
steps:
10+
-
11+
name: Set up QEMU
12+
uses: docker/setup-qemu-action@v3
13+
-
14+
name: Set up Docker Buildx
15+
uses: docker/setup-buildx-action@v3
16+
-
17+
name: Login to Docker Hub
18+
uses: docker/login-action@v3
19+
with:
20+
username: ${{ secrets.DOCKERHUB_USERNAME }}
21+
password: ${{ secrets.DOCKERHUB_TOKEN }}
22+
-
23+
name: Build and push Docker dev image
24+
uses: docker/build-push-action@v6
25+
with:
26+
push: true
27+
context: "{{defaultContext}}:notebooks"
28+
file: Dockerfile.dev
29+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/e2e-dev:latest
30+
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/e2e-dev:latest
31+
cache-to: type=inline
32+
-
33+
name: Build and push Docker prod image
34+
uses: docker/build-push-action@v6
35+
with:
36+
push: true
37+
file: Dockerfile
38+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/e2e-prod:latest
39+
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/e2e-prod:latest
40+
cache-to: type=inline

.github/workflows/test.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ jobs:
1818

1919
- name: Testing with Pytest
2020
run: |
21-
pytest --cov-report html:./reports/cov_html --cov=src/ tests/
21+
pytest --cov-report html:../reports/cov_html --cov=. ../tests/

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,15 @@ P.S.: if you are interested in modifying the code as you desire, it's better to
248248

249249
4. (OPTIONAL) Use the script included within the **data** folder to download both datasets (one for testing and the other for training and verifying the model). You can run that from your study environment as well.
250250

251-
5. Use the following command to install the pre-commit package manager:
251+
5. In order to save both Dockerfiles (for the development and production environments) in Docker Hub, you need to set up your `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` secrets in the repository's settings (`Settings > Secrets and Variables > Actions`).
252+
253+
6. Use the following command to install the pre-commit package manager:
252254

253255
```bash
254256
pip install pre-commit
255257
```
256258

257-
6. Activate pre-commit using the following command:
259+
7. Activate pre-commit using the following command:
258260

259261
```bash
260262
pre-commit install
@@ -309,6 +311,10 @@ docker compose up -d --no-deps --build test
309311

310312
12. It should take a few seconds for the tests to complete. After that, you can run `docker logs <TEST_CONTAINER_ID>` to see the overall results or view the test coverage by looking at the `cov_html` folder inside the `reports` folder.
311313

314+
13. The docker's GitHub action/workflow will save both Dockerfiles (one for the develop/research environment and the other for the production environmet) images in your DockerHub's profile, as illustrated in the figure below.
315+
316+
![Docker Hub](images/dockerhub.png)
317+
312318
DISCLAIMER: Just the workflow in the research environment was tested with AWS because of financial constraints. Docker Compose should be used to run everything locally in order to fully experience both research and production workflows.
313319

314320
<p align="right">(<a href="#readme-top">back to top</a>)</p>
@@ -317,7 +323,7 @@ DISCLAIMER: Just the workflow in the research environment was tested with AWS be
317323
## Roadmap
318324

319325
- [ ] Add end-to-end test cases.
320-
- [ ] Add a Continuous Delivery (CD) GitHub Action.
326+
- [X] Add a Continuous Delivery (CD) GitHub Action.
321327
- [ ] Add a integration test case to assure that the model's performance showed in MLflow is the same when evaluating the model on the same data, but using the API's code.
322328
- [ ] Integrate uvicorn to FastAPI.
323329
- [ ] Fix the test GitHub's workflow (it's not finishing because needs connection with FastAPI and MLflow to validate some tests).

docker-compose.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ services:
44
image: e2e-dev:latest
55

66
build:
7-
context: ./notebooks/
8-
dockerfile: ./Dockerfile.dev
7+
context: .
8+
dockerfile: ./notebooks/Dockerfile.dev
99

1010
depends_on:
1111
- mlflow

images/dockerhub.png

44.5 KB
Loading

notebooks/Dockerfile.dev

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN apt-get update && apt-get install -y python3.10 python3.10-venv python3.10-d
88
RUN mkdir -p /e2e-project/notebooks
99

1010
# copying all the files within this folder to the newly created folder
11-
COPY . /e2e-project/notebooks
11+
COPY /notebooks /e2e-project/notebooks/
1212

1313
# setting the curreting directory to be the folder containing the notebooks
1414
WORKDIR /e2e-project

0 commit comments

Comments
 (0)