Skip to content

Image Pipeline Playground

chore: update Dockerfile and CI workflows

Mohammad Rajaei565c22f17be5
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..47e61ed
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,25 @@
+version: 2
+updates:
+ - package-ecosystem: npm
+ directory: /frontend
+ schedule:
+ interval: weekly
+ open-pull-requests-limit: 5
+
+ - package-ecosystem: npm
+ directory: /desktop
+ schedule:
+ interval: weekly
+ open-pull-requests-limit: 5
+
+ - package-ecosystem: uv
+ directory: /backend
+ schedule:
+ interval: weekly
+ open-pull-requests-limit: 5
+
+ - package-ecosystem: github-actions
+ directory: /
+ schedule:
+ interval: weekly
+ open-pull-requests-limit: 5
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..f366912
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,81 @@
+name: CI
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+ branches: [main]
+ workflow_dispatch:
+ workflow_call:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ci-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ frontend:
+ name: Frontend
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ defaults:
+ run:
+ working-directory: frontend
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: "24"
+ cache: npm
+ cache-dependency-path: frontend/package-lock.json
+
+ - name: Install
+ run: npm ci
+
+ - name: Typecheck
+ run: npm run typecheck
+
+ - name: Lint
+ run: npm run lint
+
+ - name: Test
+ run: npm run test
+
+ - name: Build
+ run: npm run build
+
+ backend:
+ name: Backend
+ runs-on: ubuntu-latest
+ timeout-minutes: 20
+ defaults:
+ run:
+ working-directory: backend
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Setup Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: "3.11"
+
+ - name: Setup uv
+ uses: astral-sh/setup-uv@v6
+ with:
+ enable-cache: true
+ cache-dependency-glob: backend/uv.lock
+
+ - name: Install
+ run: uv sync --frozen --group dev
+
+ - name: Lint
+ run: uv run ruff check
+
+ - name: Test
+ run: uv run pytest
diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.yml
index f8aa2c3..d9221fa 100644
--- a/.github/workflows/desktop.yml
+++ b/.github/workflows/desktop.yml
@@ -2,19 +2,38 @@ name: Desktop
on:
push:
- branches: [main]
tags: ["v*"]
pull_request:
branches: [main]
+ paths:
+ - "desktop/**"
+ - "frontend/**"
+ - "backend/**"
+ - "scripts/build-desktop.mjs"
+ - ".github/workflows/desktop.yml"
+ - ".github/workflows/ci.yml"
workflow_dispatch:
+permissions:
+ contents: read
+
concurrency:
group: desktop-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
+ quality:
+ name: Quality gates
+ if: startsWith(github.ref, 'refs/tags/v')
+ uses: ./.github/workflows/ci.yml
+
build:
name: Build (${{ matrix.artifact }})
+ needs: quality
+ # Tag releases require green CI; PRs / manual runs skip the quality job.
+ if: |
+ always() &&
+ (needs.quality.result == 'success' || needs.quality.result == 'skipped')
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 8eafdb1..b42b867 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -1,15 +1,10 @@
name: Docker
on:
+ # Path filters on push would skip tag-only publishes; keep filters on PRs only.
push:
branches: [main]
- paths:
- - "Dockerfile"
- - "docker-compose.yml"
- - ".dockerignore"
- - "frontend/**"
- - "backend/**"
- - ".github/workflows/docker.yml"
+ tags: ["v*"]
pull_request:
branches: [main]
paths:
@@ -21,6 +16,9 @@ on:
- ".github/workflows/docker.yml"
workflow_dispatch:
+permissions:
+ contents: read
+
concurrency:
group: docker-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
@@ -30,6 +28,9 @@ jobs:
name: Build image
runs-on: ubuntu-latest
timeout-minutes: 45
+ permissions:
+ contents: read
+ packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -37,20 +38,49 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
+ - name: Login to GHCR
+ if: startsWith(github.ref, 'refs/tags/v')
+ uses: docker/login-action@v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Docker metadata
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ${{ startsWith(github.ref, 'refs/tags/v') && format('ghcr.io/{0}', github.repository) || 'image-pipes' }}
+ tags: |
+ type=semver,pattern={{version}}
+ type=semver,pattern={{major}}.{{minor}}
+ type=raw,value=ci,enable=${{ !startsWith(github.ref, 'refs/tags/v') }}
+ type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
+
- name: Build
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
- push: false
- load: true
- tags: image-pipes:ci
+ # load and push are mutually exclusive; push versioned images on tags only.
+ push: ${{ startsWith(github.ref, 'refs/tags/v') }}
+ load: ${{ !startsWith(github.ref, 'refs/tags/v') }}
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Smoke health check
run: |
- docker run -d --name image-pipes-ci -p 8000:8000 image-pipes:ci
+ set -euo pipefail
+ if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
+ VERSION="${GITHUB_REF_NAME#v}"
+ IMAGE="ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]'):${VERSION}"
+ docker pull "$IMAGE"
+ else
+ IMAGE="image-pipes:ci"
+ fi
+ docker run -d --name image-pipes-ci -p 8000:8000 "$IMAGE"
for i in $(seq 1 30); do
if curl -fsS http://127.0.0.1:8000/api/health; then
echo
diff --git a/Dockerfile b/Dockerfile
index 86fbf5c..c79fefc 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -16,7 +16,9 @@ RUN apt-get update \
libglib2.0-0 \
libgomp1 \
libgl1 \
- && rm -rf /var/lib/apt/lists/*
+ && rm -rf /var/lib/apt/lists/* \
+ && groupadd --gid 10001 app \
+ && useradd --uid 10001 --gid app --shell /usr/sbin/nologin --create-home app
COPY --from=ghcr.io/astral-sh/uv:0.9.5 /uv /usr/local/bin/uv
@@ -36,6 +38,8 @@ RUN uv sync --frozen --no-dev \
COPY --from=frontend-build /app/frontend/dist /app/frontend/dist
+RUN chown -R app:app /app
+
ENV IMAGE_PIPES_HOST=0.0.0.0 \
IMAGE_PIPES_PORT=8000 \
IMAGE_PIPES_DATA_DIR=/app/backend \
@@ -43,6 +47,8 @@ ENV IMAGE_PIPES_HOST=0.0.0.0 \
IMAGE_PIPES_LOG_LEVEL=warning \
PYTHONUNBUFFERED=1
+USER app
+
EXPOSE 8000
HEALTHCHECK --interval=15s --timeout=5s --start-period=25s --retries=5 \