Skip to content

Commit 0fd30d0

Browse files
authored
feat: add docker images (#133)
* feat: add docker images * fix: resolve PR comments * ci: docker prefer local build
1 parent dca6be3 commit 0fd30d0

7 files changed

Lines changed: 343 additions & 14 deletions

File tree

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: Build and Publish Docker Images
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: "Version tag (e.g., v1.0.0)"
10+
required: true
11+
type: string
12+
13+
concurrency:
14+
group: docker-${{ github.ref }}
15+
cancel-in-progress: false
16+
17+
env:
18+
REGISTRY: ghcr.io
19+
IMAGE_NAME_API: ${{ github.repository }}/api
20+
IMAGE_NAME_APP: ${{ github.repository }}/app
21+
22+
jobs:
23+
check-release-type:
24+
name: Check if this is an app release
25+
runs-on: ubuntu-latest
26+
outputs:
27+
should-build: ${{ steps.check.outputs.should-build }}
28+
version: ${{ steps.check.outputs.version }}
29+
steps:
30+
- name: Check release tag format
31+
id: check
32+
run: |
33+
TAG="${{ github.event.release.tag_name || github.event.inputs.version }}"
34+
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
35+
echo "should-build=true" >> $GITHUB_OUTPUT
36+
echo "version=$TAG" >> $GITHUB_OUTPUT
37+
echo "✅ App release detected: $TAG"
38+
elif [[ "$TAG" =~ ^@tuvixrss/ ]]; then
39+
echo "should-build=false" >> $GITHUB_OUTPUT
40+
echo "⏭️ Package release detected: $TAG - skipping Docker build"
41+
else
42+
echo "should-build=true" >> $GITHUB_OUTPUT
43+
echo "version=$TAG" >> $GITHUB_OUTPUT
44+
echo "⚠️ Unknown tag format: $TAG - proceeding with build"
45+
fi
46+
47+
build-and-push-api:
48+
name: Build and Push API Image
49+
runs-on: ubuntu-latest
50+
needs: [check-release-type]
51+
if: needs.check-release-type.outputs.should-build == 'true'
52+
permissions:
53+
contents: read
54+
packages: write
55+
steps:
56+
- name: Checkout repository
57+
uses: actions/checkout@v4
58+
59+
- name: Set up Docker Buildx
60+
uses: docker/setup-buildx-action@v3
61+
62+
- name: Log in to Container Registry
63+
uses: docker/login-action@v3
64+
with:
65+
registry: ${{ env.REGISTRY }}
66+
username: ${{ github.actor }}
67+
password: ${{ secrets.GITHUB_TOKEN }}
68+
69+
- name: Extract metadata
70+
id: meta
71+
uses: docker/metadata-action@v5
72+
with:
73+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_API }}
74+
tags: |
75+
type=semver,pattern={{version}}
76+
type=semver,pattern={{major}}.{{minor}}
77+
type=semver,pattern={{major}}
78+
type=raw,value=latest
79+
80+
- name: Build and push API image
81+
uses: docker/build-push-action@v6
82+
with:
83+
context: .
84+
file: ./packages/api/Dockerfile
85+
push: true
86+
tags: ${{ steps.meta.outputs.tags }}
87+
labels: ${{ steps.meta.outputs.labels }}
88+
cache-from: type=gha
89+
cache-to: type=gha,mode=max
90+
platforms: linux/amd64,linux/arm64
91+
92+
build-and-push-app:
93+
name: Build and Push App Image
94+
runs-on: ubuntu-latest
95+
needs: [check-release-type]
96+
if: needs.check-release-type.outputs.should-build == 'true'
97+
permissions:
98+
contents: read
99+
packages: write
100+
steps:
101+
- name: Checkout repository
102+
uses: actions/checkout@v4
103+
104+
- name: Set up Docker Buildx
105+
uses: docker/setup-buildx-action@v3
106+
107+
- name: Log in to Container Registry
108+
uses: docker/login-action@v3
109+
with:
110+
registry: ${{ env.REGISTRY }}
111+
username: ${{ github.actor }}
112+
password: ${{ secrets.GITHUB_TOKEN }}
113+
114+
- name: Extract metadata
115+
id: meta
116+
uses: docker/metadata-action@v5
117+
with:
118+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_APP }}
119+
tags: |
120+
type=semver,pattern={{version}}
121+
type=semver,pattern={{major}}.{{minor}}
122+
type=semver,pattern={{major}}
123+
type=raw,value=latest
124+
125+
- name: Build and push App image
126+
uses: docker/build-push-action@v6
127+
with:
128+
context: .
129+
file: ./packages/app/Dockerfile
130+
push: true
131+
tags: ${{ steps.meta.outputs.tags }}
132+
labels: ${{ steps.meta.outputs.labels }}
133+
build-args: |
134+
VITE_API_URL=http://localhost:3001/trpc
135+
VITE_APP_VERSION=${{ needs.check-release-type.outputs.version }}
136+
cache-from: type=gha
137+
cache-to: type=gha,mode=max
138+
platforms: linux/amd64,linux/arm64
139+
140+
create-summary:
141+
name: Create Deployment Summary
142+
runs-on: ubuntu-latest
143+
needs: [check-release-type, build-and-push-api, build-and-push-app]
144+
if: needs.check-release-type.outputs.should-build == 'true'
145+
steps:
146+
- name: Generate summary
147+
run: |
148+
VERSION="${{ needs.check-release-type.outputs.version }}"
149+
echo "# 🐳 Docker Images Published" >> $GITHUB_STEP_SUMMARY
150+
echo "" >> $GITHUB_STEP_SUMMARY
151+
echo "**Version:** \`$VERSION\`" >> $GITHUB_STEP_SUMMARY
152+
echo "" >> $GITHUB_STEP_SUMMARY
153+
echo "## Images" >> $GITHUB_STEP_SUMMARY
154+
echo "" >> $GITHUB_STEP_SUMMARY
155+
echo "- **API:** \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME_API }}:$VERSION\`" >> $GITHUB_STEP_SUMMARY
156+
echo "- **App:** \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME_APP }}:$VERSION\`" >> $GITHUB_STEP_SUMMARY
157+
echo "" >> $GITHUB_STEP_SUMMARY
158+
echo "## Usage" >> $GITHUB_STEP_SUMMARY
159+
echo "" >> $GITHUB_STEP_SUMMARY
160+
echo '```yaml' >> $GITHUB_STEP_SUMMARY
161+
echo 'services:' >> $GITHUB_STEP_SUMMARY
162+
echo ' api:' >> $GITHUB_STEP_SUMMARY
163+
echo " image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_API }}:$VERSION" >> $GITHUB_STEP_SUMMARY
164+
echo ' # ... rest of config' >> $GITHUB_STEP_SUMMARY
165+
echo ' app:' >> $GITHUB_STEP_SUMMARY
166+
echo " image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_APP }}:$VERSION" >> $GITHUB_STEP_SUMMARY
167+
echo ' # ... rest of config' >> $GITHUB_STEP_SUMMARY
168+
echo '```' >> $GITHUB_STEP_SUMMARY

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,36 @@ Tuvix supports two deployment methods:
3232

3333
See the **[Deployment Guide](./docs/deployment.md)** for detailed instructions.
3434

35-
> **📦 Docker Images Coming Soon:** Pre-built container images will be published to a container registry once the project reaches a stable release. For now, use the Dockerfiles and docker-compose scripts included in the repository.
36-
3735
### Quick Start (Docker)
3836

37+
The docker-compose.yml works with both pre-built images and source builds:
38+
39+
**Option 1: Pre-built Images (Recommended - Fast)**
40+
41+
```bash
42+
# Create directory and download files
43+
mkdir Tuvix-RSS && cd Tuvix-RSS
44+
curl -O https://raw.githubusercontent.com/TechSquidTV/Tuvix-RSS/main/docker-compose.yml
45+
curl -O https://raw.githubusercontent.com/TechSquidTV/Tuvix-RSS/main/env.example
46+
cp env.example .env
47+
48+
# Edit .env and configure:
49+
# 1. BETTER_AUTH_SECRET (generate: openssl rand -base64 32)
50+
# 2. Admin credentials (ADMIN_USERNAME, ADMIN_EMAIL, ADMIN_PASSWORD)
51+
nano .env
52+
53+
# Pin to specific version (optional)
54+
export VERSION=v0.6.1 # Or use 'latest' for newest
55+
56+
# Pull images and start
57+
docker compose pull
58+
docker compose up -d
59+
60+
# Access at http://localhost:5173
61+
```
62+
63+
**Option 2: Build from Source**
64+
3965
> **⚠️ Use a Release:** The `main` branch contains active development and is not guaranteed to be stable. Always use the latest release for self-hosting.
4066
4167
Clone the repository and checkout the latest release:
@@ -54,6 +80,14 @@ cp env.example .env
5480
# Edit .env and configure:
5581
# 1. BETTER_AUTH_SECRET (generate: openssl rand -base64 32)
5682
# 2. ADMIN_USERNAME, ADMIN_EMAIL, ADMIN_PASSWORD (for your admin user)
83+
nano .env
84+
85+
# Build and start (includes git version in settings)
86+
pnpm run docker:build
87+
docker compose up -d
88+
89+
# Or build without version script
90+
docker compose build
5791
docker compose up -d
5892
```
5993

docker-compose.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
services:
22
api:
3+
image: ghcr.io/techsquidtv/tuvix-rss/api:${VERSION:-latest}
34
build:
45
context: .
56
dockerfile: ./packages/api/Dockerfile
@@ -46,12 +47,14 @@ services:
4647
- tuvix-network
4748

4849
app:
50+
image: ghcr.io/techsquidtv/tuvix-rss/app:${VERSION:-latest}
51+
pull_policy: build
4952
build:
5053
context: .
5154
dockerfile: ./packages/app/Dockerfile
5255
args:
5356
- VITE_API_URL=${VITE_API_URL:-http://localhost:3001/trpc}
54-
pull_policy: build
57+
- VITE_APP_VERSION=${VITE_APP_VERSION:-docker}
5558
container_name: tuvix-app
5659
restart: unless-stopped
5760
ports:

0 commit comments

Comments
 (0)