File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Build & Push - Main
2+
3+ on :
4+ push :
5+ branches : [main]
6+
7+ jobs :
8+ build-and-push :
9+ runs-on : ubuntu-latest
10+
11+ steps :
12+ - uses : actions/checkout@v4
13+
14+ - name : Log in to DockerHub
15+ uses : docker/login-action@v3
16+ with :
17+ username : ${{ secrets.DOCKER_USERNAME }}
18+ password : ${{ secrets.DOCKER_TOKEN }}
19+
20+ - name : Build & push main image
21+ uses : docker/build-push-action@v5
22+ with :
23+ context : .
24+ push : true
25+ tags : ${{ secrets.DOCKER_USERNAME }}/python-sample:main
Original file line number Diff line number Diff line change 1+ name : Build & Push - Test
2+
3+ on :
4+ push :
5+ branches : [test]
6+
7+ jobs :
8+ build-and-push :
9+ runs-on : ubuntu-latest
10+
11+ steps :
12+ - uses : actions/checkout@v4
13+
14+ - name : Log in to DockerHub
15+ uses : docker/login-action@v3
16+ with :
17+ username : ${{ secrets.DOCKER_USERNAME }}
18+ password : ${{ secrets.DOCKER_TOKEN }}
19+
20+ - name : Build & push test image
21+ uses : docker/build-push-action@v5
22+ with :
23+ context : .
24+ push : true
25+ tags : ${{ secrets.DOCKER_USERNAME }}/python-sample:test
Original file line number Diff line number Diff line change 1+ FROM python:3.11-slim
2+ WORKDIR /app
3+ COPY . .
4+ EXPOSE 80
5+
6+ RUN pip install --no-cache-dir -r requirements.txt
7+ CMD ["python" , "app.py" ]
Original file line number Diff line number Diff line change 1+ from flask import Flask
2+ app = Flask (__name__ )
3+
4+ @app .route ('/' )
5+ def home ():
6+ return "Hello from Python in Docker!"
7+
8+ if __name__ == '__main__' :
9+ app .run (host = '0.0.0.0' , port = 80 )
Original file line number Diff line number Diff line change 1+ flask
You can’t perform that action at this time.
0 commit comments