Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
57 changes: 57 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish Docker Image to GHCR

on:
push:
branches: [main]
tags: ['v*']
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/github-stars-manager-server

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v6
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

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

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# branch push → "latest"
type=raw,value=latest,enable={{is_default_branch}}
# tag push → "v1.2.3", "1.2.3", "1.2", "1"
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
# every build → sha-abc1234
type=sha,prefix=sha-

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./server
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
101 changes: 83 additions & 18 deletions DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,93 @@ This application can be deployed using Docker with minimal configuration. The Do
- Docker installed on your system
- Docker Compose (optional, but recommended)

## Building and Running with Docker
## Quick Start (Using Pre-built Images from GHCR)

### Using Docker Compose (Recommended)
The fastest way to get started — no build required:

```bash
# Build and start the container
# Using Docker Compose (pulls images automatically)
docker-compose up -d

# The application will be available at http://localhost:8080
```

### Using Docker directly
Available image tags:
- `latest` — latest build from the `main` branch
- `v0.6.2`, `0.6.2` — specific version tags
- `sha-abc1234` — specific commit builds

Comment thread
coderabbitai[bot] marked this conversation as resolved.
## Backend Server (docker run)

The backend image is published to GHCR and can be run standalone:

```bash
# Basic — no auth, port 3000, data persisted in volume
docker run -d \
--name github-stars-backend \
-v github-stars-data:/app/data \
-p 3000:3000 \
ghcr.io/amintacccp/github-stars-manager-server:latest

# With custom API secret and encryption key
docker run -d \
--name github-stars-backend \
-v github-stars-data:/app/data \
-p 3000:3000 \
-e API_SECRET="your-secret-here" \
-e ENCRYPTION_KEY="your-encryption-key" \
ghcr.io/amintacccp/github-stars-manager-server:latest

# Map to a different host port (e.g. 8080)
docker run -d \
--name github-stars-backend \
-v github-stars-data:/app/data \
-p 8080:3000 \
-e API_SECRET="your-secret-here" \
ghcr.io/amintacccp/github-stars-manager-server:latest
```

### Environment Variables

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `API_SECRET` | No | `null` (auth disabled) | Bearer token for API authentication |
| `ENCRYPTION_KEY` | No | Auto-generated (saved to `data/.encryption-key`) | AES-256 key for encrypting stored secrets. Accepts any format — 64-char hex, shorter hex, base64, or plain text (all normalized via SHA-256) |
| `PORT` | No | `3000` | Server listening port |
| `DB_PATH` | No | `data/data.db` | Path to SQLite database file |

> **Note:** The data volume (`/app/data`) stores both the database and the auto-generated encryption key. Always mount it to persist data across container restarts.

## Full Stack with Docker Compose

`docker-compose.yml` runs both frontend and backend:

```bash
docker-compose up -d
```

To customize secrets, create a `.env` file in the project root:

```bash
API_SECRET=my-strong-secret
ENCRYPTION_KEY=my-encryption-key
```

Then `docker-compose up -d` reads them automatically.

## Building Locally with Docker

### Using Docker Compose (local build)

Edit `docker-compose.yml` — comment out the `image:` line and uncomment `build: ./server`, then:

```bash
docker-compose up -d --build

# The application will be available at http://localhost:8080
```

### Using Docker directly (frontend only)

```bash
# Build the image
Expand All @@ -38,27 +113,17 @@ This Docker setup handles CORS in two ways:

2. **Client-Side Handling**: The application is designed to work with any AI or WebDAV service URL configured by the user, without requiring proxying.

## Configuration

No special configuration is needed for the Docker container itself. All application settings (API URLs, credentials, etc.) are configured through the application UI.

## Environment Variables

While not required, you can pass environment variables to the container if needed:

```bash
docker run -d -p 8080:80 -e NODE_ENV=production --name github-stars-manager github-stars-manager
```

## Stopping the Container

```bash
# With Docker Compose
docker-compose down

# With Docker directly
docker stop github-stars-manager
docker rm github-stars-manager
docker stop github-stars-manager && docker rm github-stars-manager

# Stop backend only
docker stop github-stars-backend && docker rm github-stars-backend
```

## Note on Desktop Packaging
Expand Down
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,14 @@ https://github.com/AmintaCCCP/GithubStarsManager/releases

### 🐳 Run With Docker

You can also run this application using Docker. See [DOCKER.md](DOCKER.md) for detailed instructions on how to build and deploy using Docker. The Docker setup handles CORS properly and allows you to configure any AI or WebDAV service URLs directly in the application.
Pre-built backend image is available on GHCR — no local build required:

```bash
docker pull ghcr.io/amintacccp/github-stars-manager-server:latest
docker-compose up -d
```

See [DOCKER.md](DOCKER.md) for detailed instructions. The Docker setup handles CORS properly and allows you to configure any AI or WebDAV service URLs directly in the application.

### 🖥️ Backend Server (Optional)

Expand All @@ -182,10 +189,27 @@ The app works fully without a backend (pure frontend, localStorage). An optional

#### Quick Start (Docker — recommended)
```bash
docker-compose up --build
docker-compose up -d
```
Frontend on port 8080, backend on port 3000. Data persisted in a Docker volume.

#### Backend only (docker run)
```bash
# Basic — no auth, port 3000
docker run -d --name github-stars-backend \
-v github-stars-data:/app/data \
-p 3000:3000 \
ghcr.io/amintacccp/github-stars-manager-server:latest

# With custom secret and encryption key
docker run -d --name github-stars-backend \
-v github-stars-data:/app/data \
-p 3000:3000 \
-e API_SECRET="your-secret" \
-e ENCRYPTION_KEY="your-key" \
ghcr.io/amintacccp/github-stars-manager-server:latest
```

#### Manual Setup
```bash
cd server
Expand Down
29 changes: 27 additions & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,15 @@ npm run build
- 自建服务器

### Docker 部署
您也可以使用 Docker 来运行此应用程序。请参阅 [DOCKER.md](DOCKER.md) 获取详细的构建和部署说明。Docker 设置正确处理了 CORS,并允许您直接在应用程序中配置任何 AI 或 WebDAV 服务 URL。

GHCR 上有预构建的后端镜像,无需本地构建:

```bash
docker pull ghcr.io/amintacccp/github-stars-manager-server:latest
docker-compose up -d
```

请参阅 [DOCKER.md](DOCKER.md) 获取详细的构建和部署说明。Docker 设置正确处理了 CORS,并允许您直接在应用程序中配置任何 AI 或 WebDAV 服务 URL。

### 🖥️ 后端服务器(可选)

Expand All @@ -240,10 +248,27 @@ npm run build

#### 快速启动(推荐使用 Docker)
```bash
docker-compose up --build
docker-compose up -d
```
前端运行在 8080 端口,后端运行在 3000 端口。数据持久化存储在 Docker 卷中。

#### 仅后端(docker run)
```bash
# 基础运行 — 无认证,端口 3000
docker run -d --name github-stars-backend \
-v github-stars-data:/app/data \
-p 3000:3000 \
ghcr.io/amintacccp/github-stars-manager-server:latest

# 自定义密钥和端口
docker run -d --name github-stars-backend \
-v github-stars-data:/app/data \
-p 3000:3000 \
-e API_SECRET="your-secret" \
-e ENCRYPTION_KEY="your-key" \
ghcr.io/amintacccp/github-stars-manager-server:latest
```

#### 手动启动
```bash
cd server
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ services:
restart: unless-stopped

backend:
build: ./server
image: ghcr.io/amintacccp/github-stars-manager-server:latest
# Uncomment below (and comment out 'image') to build locally instead:
# build: ./server
expose:
- "3000"
environment:
Expand Down
Loading