Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4e0ed93
Merge pull request #7 from JosunLP/dev
JosunLP Oct 29, 2025
7ce7ce8
Initial plan
Copilot Oct 30, 2025
a5c909b
Add native macOS support for builds and releases
Copilot Oct 30, 2025
cca113d
Refactor: consolidate Unix installation logic for Linux and macOS
Copilot Oct 30, 2025
f5e4143
🐛 Korrigiere SHA256-Checksumme für Linux und macOS; füge Fehlerausgab…
JosunLP Nov 1, 2025
f28bd5c
🐛 Verbessere Fehlerausgabe für nicht unterstützte macOS-Architekturen
JosunLP Nov 1, 2025
c3aba12
Merge branch 'copilot/add-macos-support-release' into dev
JosunLP Nov 2, 2025
45bc16f
Feature: Rotation (#11)
JosunLP Dec 4, 2025
83e4149
Add Docker deployment target with automated Docker Hub publishing (#13)
Copilot Dec 5, 2025
3d4eaf8
Potential fix for code scanning alert no. 1: Workflow does not contai…
JosunLP Dec 5, 2025
4d3f253
Update src/api.rs
JosunLP Dec 5, 2025
f2a0196
Add conditional checks to Docker workflow for missing secrets (#18)
Copilot Dec 5, 2025
c2bbf65
Revert invalid secret conditionals in Docker workflow (#19)
Copilot Dec 5, 2025
77f1116
Add unit tests for parse_bool and clarify allow_rotations API fallbac…
Copilot Dec 8, 2025
fc9635f
fmt
JosunLP Dec 11, 2025
3a956b4
Update dependencies and improve API route handling
JosunLP Dec 11, 2025
95ba14b
Update version to 1.1.0 and enhance Docker setup documentation
JosunLP Dec 11, 2025
37feb52
Refine Docker configuration and clarify axum 0.8 route syntax (#23)
Copilot Dec 12, 2025
5d63499
Add test coverage for allow_rotations field parsing and override beha…
Copilot Dec 12, 2025
fee94cd
Update CHANGELOG
JosunLP Dec 12, 2025
7bb3420
Update CHANGELOG
JosunLP Dec 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Git files
.git
.gitignore
.github

# Rust build artifacts
target/

# Documentation
*.md
Comment thread
JosunLP marked this conversation as resolved.
Outdated
CHANGELOG
LICENSE

# Environment files
.env
.env.example

# Scripts
scripts/

# Node files
package.json
node_modules/
51 changes: 51 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Docker Build and Push

on:
push:
tags:
- "v*"
# Manual dispatch builds and pushes images based on metadata-action tags
workflow_dispatch:

permissions:
contents: read

jobs:
docker:
name: Build and Push Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Note: Ensure DOCKER_USERNAME and DOCKER_PASSWORD secrets are configured
Comment thread
JosunLP marked this conversation as resolved.

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKER_USERNAME }}/sort-it-now
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
Comment thread
JosunLP marked this conversation as resolved.

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
18 changes: 15 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ jobs:
label: Windows x86_64
artifact_suffix: windows-x86_64
archive_extension: zip
- os: macos-latest
label: macOS ARM64 (Apple Silicon)
artifact_suffix: macos-arm64
archive_extension: tar.gz
- os: macos-13
label: macOS x86_64 (Intel)
artifact_suffix: macos-x86_64
archive_extension: tar.gz
steps:
- uses: actions/checkout@v4

Expand All @@ -44,8 +52,8 @@ jobs:
- name: Build release binary
run: cargo build --release

- name: Package artifact (Linux)
if: matrix.os == 'ubuntu-latest'
- name: Package artifact (Linux/macOS)
if: matrix.os == 'ubuntu-latest' || startsWith(matrix.os, 'macos')
env:
VERSION: ${{ steps.meta.outputs.version }}
SUFFIX: ${{ matrix.artifact_suffix }}
Expand All @@ -62,7 +70,11 @@ jobs:
cp scripts/install-unix.sh "$BUNDLE_DIR/install.sh"
chmod +x "$BUNDLE_DIR/install.sh"
tar -czf "$ARCHIVE_PATH" "$BUNDLE_DIR"
sha256sum "$ARCHIVE_PATH" > "$ARCHIVE_PATH.sha256"
if [[ "$RUNNER_OS" == "Linux" ]]; then
sha256sum "$ARCHIVE_PATH" > "$ARCHIVE_PATH.sha256"
else
shasum -a 256 "$ARCHIVE_PATH" | awk '{printf "%s %s\n", $1, $2}' > "$ARCHIVE_PATH.sha256"
fi

- name: Package artifact (Windows)
if: matrix.os == 'windows-latest'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Rust
permissions:
contents: read

on:
push:
Expand Down
120 changes: 120 additions & 0 deletions DOCKER_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Docker Hub Deployment Setup

Diese Anleitung beschreibt, wie man die automatische Docker-Veröffentlichung auf Docker Hub einrichtet.

## Voraussetzungen

1. Ein Docker Hub Account (https://hub.docker.com/)
2. Repository-Admin-Zugriff auf GitHub

## Schritt 1: Docker Hub Access Token erstellen

1. Gehe zu https://hub.docker.com/settings/security
2. Klicke auf "New Access Token"
3. Gib einen Namen ein (z.B. "github-actions-sort-it-now")
4. Wähle die Berechtigung "Read, Write" aus
5. Klicke auf "Generate"
6. **Wichtig:** Kopiere das Token sofort - es wird nur einmal angezeigt!

## Schritt 2: GitHub Secrets konfigurieren

1. Gehe zu deinem GitHub Repository
2. Navigiere zu **Settings** → **Secrets and variables** → **Actions**
3. Klicke auf "New repository secret"
4. Erstelle zwei Secrets:

**Secret 1:**
- Name: `DOCKER_USERNAME`
- Value: Dein Docker Hub Benutzername

**Secret 2:**
- Name: `DOCKER_PASSWORD`
- Value: Das Access Token aus Schritt 1

## Schritt 3: Workflow testen

Der Docker-Workflow wird automatisch ausgelöst, wenn:
- Ein neuer Tag im Format `v*` erstellt wird (z.B. `v1.0.0`)
- Der Workflow manuell über "Actions" → "Docker Build and Push" → "Run workflow" gestartet wird

### Manueller Test:

1. Gehe zu **Actions** im GitHub Repository
2. Wähle den Workflow "Docker Build and Push"
3. Klicke auf "Run workflow"
4. Wähle den Branch aus
5. Klicke auf "Run workflow"

## Schritt 4: Docker Image auf Docker Hub verifizieren

Nach erfolgreichem Workflow-Durchlauf:

1. Gehe zu https://hub.docker.com/
2. Navigiere zu deinem Repository
3. Das Image sollte mit den entsprechenden Tags verfügbar sein:
- `latest` (wird bei jedem Release mit einem `v*` Tag vergeben)
- Versions-Tags (z.B. `1.0.0`, `1.0`, `1`)

## Docker Image verwenden

Nach der Veröffentlichung kann das Image folgendermaßen verwendet werden:

> **Hinweis:** Ersetze `<your-dockerhub-username>` durch deinen tatsächlichen Docker Hub Benutzernamen.

```bash
# Neueste Version
docker pull <your-dockerhub-username>/sort-it-now:latest

# Spezifische Version
docker pull <your-dockerhub-username>/sort-it-now:1.0.0

# Ausführen
docker run -p 8080:8080 -e SORT_IT_NOW_SKIP_UPDATE_CHECK=1 <your-dockerhub-username>/sort-it-now:latest
```

## Troubleshooting

### Workflow schlägt mit "Authentication failed" fehl
- Überprüfe, ob die Secrets korrekt gesetzt sind
- Stelle sicher, dass das Docker Hub Access Token nicht abgelaufen ist
- Verifiziere den Docker Hub Benutzernamen (Groß-/Kleinschreibung beachten)

### Workflow schlägt mit "denied: requested access to the resource is denied" fehl
- Das Access Token benötigt "Write"-Berechtigung
- Stelle sicher, dass das Repository auf Docker Hub existiert (wird automatisch beim ersten Push erstellt)

### Image wird nicht mit allen Plattformen gebaut
- Docker Buildx wird automatisch eingerichtet
- Bei Problemen kann man in `.github/workflows/docker.yml` die Zeile `platforms: linux/amd64,linux/arm64` auf nur `linux/amd64` reduzieren

## Anpassungen

### Docker Hub Repository-Name ändern

In `.github/workflows/docker.yml` die Zeile:
```yaml
images: ${{ secrets.DOCKER_USERNAME }}/sort-it-now
```

ändern zu:
```yaml
images: ${{ secrets.DOCKER_USERNAME }}/dein-repository-name
```

### Andere Registry verwenden (z.B. GitHub Container Registry)

Für GitHub Container Registry (ghcr.io):
1. Ersetze `docker/login-action` mit GitHub Token:
```yaml
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
```

2. Ändere das Image in `metadata-action`:
```yaml
images: ghcr.io/${{ github.repository_owner }}/sort-it-now
```
54 changes: 54 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Build stage
FROM rust:1 AS builder

# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy manifests and build dependencies first for better layer caching
COPY Cargo.toml ./
# Note: Cargo.lock is gitignored in this project, so dependencies will resolve at build time
# Create a dummy main.rs to build dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release && rm -rf src

# Copy actual source code
Comment thread
JosunLP marked this conversation as resolved.
COPY src ./src
COPY web ./web

# Build the application with actual source
RUN cargo build --release

# Runtime stage
FROM debian:bookworm-slim

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*

# Create non-root user for security
RUN useradd -r -u 10001 -s /usr/sbin/nologin appuser

WORKDIR /app

# Copy the binary from builder with proper ownership
COPY --from=builder --chown=appuser:appuser /app/target/release/sort_it_now /app/sort_it_now

# Expose the default port
EXPOSE 8080

# Set environment variables with defaults
ENV SORT_IT_NOW_API_HOST=0.0.0.0
ENV SORT_IT_NOW_API_PORT=8080

# Switch to non-root user
USER appuser

# Run the binary
CMD ["/app/sort_it_now"]
Loading
Loading