Hinzufügen des Docker Containerst
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 2m3s

This commit is contained in:
jafreli
2025-07-19 00:46:42 +02:00
parent f551dfe00c
commit f714fa46ba
6 changed files with 314 additions and 0 deletions

58
.dockerignore Normal file
View File

@@ -0,0 +1,58 @@
# Git
.git
.gitignore
.gitea
# Python
__pycache__
*.pyc
*.pyo
*.pyd
.Python
env
pip-log.txt
pip-delete-this-directory.txt
.tox
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.log
.git
.mypy_cache
.pytest_cache
.hypothesis
# Virtual environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# IDE
.vscode/
.idea/
*.swp
*.swo
*~
# OS
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Documentation
README.md
*.md
# Database (will be created in container)
habits.json

View File

@@ -0,0 +1,76 @@
name: Build and Push Docker Image
on:
push:
branches:
- main
- master
tags:
- 'v*'
pull_request:
branches:
- main
- master
env:
REGISTRY: git.out.jafre.li # Ersetze mit deiner Gitea-Domain
IMAGE_NAME: habit-tracker
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ gitea.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ gitea.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate deployment info
run: |
echo "## Docker Image Built Successfully! 🐳" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Image:** \`${{ env.REGISTRY }}/${{ gitea.repository_owner }}/${{ env.IMAGE_NAME }}:latest\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Quick Start:" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
echo "docker run -d \\" >> $GITHUB_STEP_SUMMARY
echo " --name habit-tracker \\" >> $GITHUB_STEP_SUMMARY
echo " -p 5000:5000 \\" >> $GITHUB_STEP_SUMMARY
echo " -v habit-data:/app/data \\" >> $GITHUB_STEP_SUMMARY
echo " ${{ env.REGISTRY }}/${{ gitea.repository_owner }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

33
Dockerfile Normal file
View File

@@ -0,0 +1,33 @@
# Use Python 3.11 slim image
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create directory for database
RUN mkdir -p /app/data
# Expose port
EXPOSE 5000
# Set environment variables
ENV FLASK_APP=app.py
ENV FLASK_ENV=production
ENV PYTHONPATH=/app
# Run the application
CMD ["python", "-m", "flask", "run", "--host=0.0.0.0", "--port=5000"]

129
README.md Normal file
View File

@@ -0,0 +1,129 @@
# Habit Tracker
Ein einfacher Habit Tracker mit wöchentlicher Ansicht, gebaut mit Flask und JavaScript.
## Features
- 📅 Wöchentliche Ansicht (7 Zeilen für jeden Wochentag)
- 🎯 Anpassbare Tagesziele (1-20x pro Tag)
- 🎨 Individuelle Farben für jedes Habit
- 🔥 Streak-Zähler
- 📱 Responsive Design
- 🐳 Docker-Support
## Schnellstart mit Docker
### Aus der Registry
```bash
docker run -d \
--name habit-tracker \
-p 5000:5000 \
-v habit-data:/app/data \
gitea.example.com/username/habit-tracker:latest
```
### Lokal bauen
```bash
# Repository klonen
git clone <repository-url>
cd habit-tracker
# Mit Docker Compose
docker-compose up -d
# Oder manuell
docker build -t habit-tracker .
docker run -d \
--name habit-tracker \
-p 5000:5000 \
-v habit-data:/app/data \
habit-tracker
```
## Lokale Entwicklung
```bash
# Virtual Environment erstellen
python -m venv venv
source venv/bin/activate # Linux/Mac
# oder
venv\Scripts\activate # Windows
# Dependencies installieren
pip install -r requirements.txt
# App starten
python app.py
```
Die App ist dann unter http://localhost:5000 erreichbar.
## Konfiguration
### Umgebungsvariablen
- `FLASK_ENV`: `production` oder `development` (Standard: `production`)
- `FLASK_APP`: `app.py` (Standard)
### Volumes
- `/app/data`: Hier wird die `habits.json` Datenbank gespeichert
## Deployment
### Docker Compose (Empfohlen)
```yaml
version: '3.8'
services:
habit-tracker:
image: gitea.example.com/username/habit-tracker:latest
ports:
- "5000:5000"
volumes:
- ./data:/app/data
environment:
- FLASK_ENV=production
restart: unless-stopped
```
### Reverse Proxy (Nginx)
```nginx
server {
listen 80;
server_name habits.example.com;
location / {
proxy_pass http://localhost:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
```
## Bedienung
1. **Habit hinzufügen**: Namen eingeben und "Hinzufügen" klicken
2. **Heute abhaken**: ✓-Button klicken (zeigt Fortschritt bei Zielen >1)
3. **Vergangene Tage bearbeiten**: Drei-Punkte-Menü → Modal öffnen
4. **Einstellungen**: Im Modal Farbe und Tagesziel anpassen
5. **Löschen**: Im Modal über den "Löschen"-Button
## Technische Details
- **Backend**: Flask (Python)
- **Frontend**: Vanilla JavaScript
- **Datenbank**: TinyDB (JSON-basiert)
- **Styling**: CSS Grid/Flexbox
- **Container**: Multi-Arch (AMD64/ARM64)
## CI/CD
Der Gitea-Workflow baut automatisch Docker-Images bei:
- Push auf `main`/`master` Branch
- Neue Tags (z.B. `v1.0.0`)
- Pull Requests
## Lizenz
MIT License

15
docker-compose.yml Normal file
View File

@@ -0,0 +1,15 @@
version: '3.8'
services:
habit-tracker:
build: .
ports:
- "5000:5000"
volumes:
- habit-data:/app/data
environment:
- FLASK_ENV=production
restart: unless-stopped
volumes:
habit-data:

3
requirements.txt Normal file
View File

@@ -0,0 +1,3 @@
Flask==2.3.3
tinydb==4.8.0
Werkzeug==2.3.7