File tree Expand file tree Collapse file tree 5 files changed +69
-0
lines changed
Expand file tree Collapse file tree 5 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 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/
Original file line number Diff line number Diff line change 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" ]
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1+ pytest
2+ gunicorn
3+ scikit-learn
4+ flask
5+ numpy
Original file line number Diff line number Diff line change 1+ def test_example ():
2+ assert 1 == 1
You can’t perform that action at this time.
0 commit comments