Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
**/tests

# Other
**/images

2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ DJANGO_LOG_LEVEL=INFO
GROQ_API_KEY=

# Langsmith (optional: Activate Langsmith tracing see: https://smith.langchain.com/)
LANGSMITH_TRACING=True
LANGSMITH_TRACING=False
LANGSMITH_ENDPOINT="https://api.smith.langchain.com"
LANGSMITH_API_KEY=
LANGSMITH_PROJECT="YT Navigator"
121 changes: 121 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# 仅手动触发:选择分支或 tag 后,用 matrix 在 amd64 / arm64 两台机器上并行构建,再合并为多架构镜像
# 公开仓库:GitHub Actions 免费(含 matrix 多 job)

name: Build and Push Docker Image

on:
workflow_dispatch:
inputs:
ref:
description: 'Branch 或 Tag(例如 main、v0.1.2)'
required: true
default: 'main'
type: string

env:
REGISTRY: ghcr.io

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
image: ${{ steps.image.outputs.image }}
add_latest: ${{ steps.version.outputs.add_latest }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}

- name: Set version and image
id: version
run: |
REF="${{ inputs.ref }}"
V=$(echo "$REF" | tr -d ' \n\r' | sed 's/[^a-zA-Z0-9_.-]/-/g' | sed 's/-\+/-/g' | sed 's/^-//;s/-$//')
echo "version=${V:-dev}" >> $GITHUB_OUTPUT
[ "$REF" = "main" ] || [ "$REF" = "master" ] && echo "add_latest=true" >> $GITHUB_OUTPUT || echo "add_latest=false" >> $GITHUB_OUTPUT
echo "Build ref: $REF -> image tag: ${V:-dev}"

- name: Set image name
id: image
run: |
OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
echo "image=${{ env.REGISTRY }}/${OWNER}/yt-navigator" >> $GITHUB_OUTPUT

build:
needs: prepare
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
suffix: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm
suffix: arm64
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}

- 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: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push (${{ matrix.suffix }})
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: ${{ matrix.platform }}
push: true
tags: ${{ needs.prepare.outputs.image }}:${{ needs.prepare.outputs.version }}-${{ matrix.suffix }}
provenance: false
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PYTHON_VERSION=3.13.2

merge:
needs: [prepare, build]
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push manifest (version + latest)
run: |
IMAGE="${{ needs.prepare.outputs.image }}"
V="${{ needs.prepare.outputs.version }}"
docker manifest create "${IMAGE}:${V}" \
"${IMAGE}:${V}-amd64" \
"${IMAGE}:${V}-arm64"
docker manifest push "${IMAGE}:${V}"
echo "Pushed ${IMAGE}:${V}"
if [ "${{ needs.prepare.outputs.add_latest }}" = "true" ]; then
docker manifest create "${IMAGE}:latest" \
"${IMAGE}:${V}-amd64" \
"${IMAGE}:${V}-arm64"
docker manifest push "${IMAGE}:latest"
echo "Pushed ${IMAGE}:latest"
fi
2 changes: 1 addition & 1 deletion app/templates/errors/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<h1 class="text-6xl font-bold text-yt-red mb-4">404</h1>
<p class="text-2xl mb-6">Page Not Found</p>
<p class="text-lg mb-8">The page you are looking for might have been removed or doesn't exist.</p>
<a href="{% url 'home' %}" class="bg-yt-red text-white px-6 py-3 rounded-lg hover:bg-red-700 transition duration-300">
<a href="{% url 'app:home' %}" class="bg-yt-red text-white px-6 py-3 rounded-lg hover:bg-red-700 transition duration-300">
Return to Home
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/errors/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<h1 class="text-6xl font-bold text-yt-red mb-4">500</h1>
<p class="text-2xl mb-6">Internal Server Error</p>
<p class="text-lg mb-8">Something went wrong on our end. Please try again later.</p>
<a href="{% url 'home' %}" class="bg-yt-red text-white px-6 py-3 rounded-lg hover:bg-red-700 transition duration-300">
<a href="{% url 'app:home' %}" class="bg-yt-red text-white px-6 py-3 rounded-lg hover:bg-red-700 transition duration-300">
Return to Home
</a>
</div>
Expand Down
Loading