Spaces:
Running
Running
Commit
·
017278f
1
Parent(s):
4bbaf9e
Feat: Added Docker CI/CD pipeline to automatically build and push Flask app to Docker Hub.
Browse files- .dockerignore +14 -0
- .github/workflows/docker-publish.yml +31 -0
- Dockerfile +13 -0
.dockerignore
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python artifacts
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.pyc
|
| 4 |
+
|
| 5 |
+
# Virtual environment files
|
| 6 |
+
venv/
|
| 7 |
+
.venv/
|
| 8 |
+
.tox/
|
| 9 |
+
|
| 10 |
+
# Local configuration and logs (crucial for security/size)
|
| 11 |
+
.env
|
| 12 |
+
.DS_Store
|
| 13 |
+
*.log
|
| 14 |
+
tmp/
|
.github/workflows/docker-publish.yml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Docker Image Build and Publish
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches:
|
| 6 |
+
- main # Trigger on any push to the main branch
|
| 7 |
+
workflow_dispatch: # Allows manual trigger
|
| 8 |
+
|
| 9 |
+
# Grant write permissions for contents (to checkout code) and ID token (for authentication)
|
| 10 |
+
jobs:
|
| 11 |
+
build_and_push:
|
| 12 |
+
runs-on: ubuntu-latest
|
| 13 |
+
steps:
|
| 14 |
+
- name: Checkout repository
|
| 15 |
+
uses: actions/checkout@v4
|
| 16 |
+
|
| 17 |
+
- name: Log in to Docker Hub
|
| 18 |
+
# Authenticates with Docker Hub using the secrets you provided
|
| 19 |
+
uses: docker/login-action@v3
|
| 20 |
+
with:
|
| 21 |
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
| 22 |
+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
| 23 |
+
|
| 24 |
+
- name: Build and push Docker image
|
| 25 |
+
uses: docker/build-push-action@v5
|
| 26 |
+
with:
|
| 27 |
+
context: .
|
| 28 |
+
push: true
|
| 29 |
+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/prompttune:latest
|
| 30 |
+
# We use 'latest' and a version tag for proper versioning
|
| 31 |
+
# You can add: ${{ secrets.DOCKERHUB_USERNAME }}/prompttune:v1.0
|
Dockerfile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a Python base image, ideal for Flask applications
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
|
| 6 |
+
COPY requirements.txt .
|
| 7 |
+
RUN pip install --no-cache-dir -r requirements.txt --default-timeout=1000 --retries=5
|
| 8 |
+
|
| 9 |
+
COPY . .
|
| 10 |
+
|
| 11 |
+
EXPOSE 5000
|
| 12 |
+
|
| 13 |
+
CMD ["python", "app.py"]
|