Skip to content

Commit 3bced5c

Browse files
committed
add ci cd and build Dockerfile
1 parent f124bde commit 3bced5c

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed

.github/workflows/ci-cd.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Docker Image CI-CD
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.x'
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v2
25+
26+
- name: Cache Docker layers
27+
uses: actions/cache@v3
28+
with:
29+
path: /tmp/.buildx-cache
30+
key: ${{ runner.os }}-buildx-${{ github.sha }}
31+
restore-keys: |
32+
${{ runner.os }}-buildx-
33+
34+
- name: Build Docker image
35+
run: docker build -t customer-churn .
36+
37+
- name: Test the application (Run tests inside container)
38+
run: docker run --rm customer-churn pytest tests/

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Use an official Python runtime as a parent image
2+
FROM python:3.11-slim
3+
4+
# Set the working directory
5+
WORKDIR /app
6+
7+
# Copy the current directory contents into the container
8+
COPY . /app
9+
10+
# Install the dependencies
11+
RUN pip install --no-cache-dir -r requirements.txt
12+
13+
# Expose the port Flask runs on
14+
EXPOSE 5000
15+
16+
# Command to run the Flask app
17+
CMD ["python", "app.py"]

render.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
services:
2+
- type: web
3+
name: customer-churn
4+
env: python
5+
buildCommand: ""
6+
startCommand: gunicorn app:app -b 0.0.0.0:$PORT
7+
plan: free

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pytest
2+
gunicorn
3+
scikit-learn
4+
flask
5+
numpy

tests/test_app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def test_example():
2+
assert 1 == 1

0 commit comments

Comments
 (0)