feat: update docker-compose and README for Synology NAS deployment
This commit is contained in:
parent
693892dfaa
commit
21963a111c
3 changed files with 132 additions and 63 deletions
187
README.md
187
README.md
|
|
@ -25,106 +25,175 @@ A modern, fast, and fully-featured YouTube-like video streaming platform. Built
|
||||||
|
|
||||||
## Docker Deployment (v9)
|
## Docker Deployment (v9)
|
||||||
|
|
||||||
### Quick Start
|
### Quick Start (Local Build)
|
||||||
|
|
||||||
1. Clone or download this repository
|
1. Clone or download this repository
|
||||||
2. Create a `data` folder in the project directory
|
2. Create a `data` folder in the project directory
|
||||||
3. Run the container:
|
3. Build and run the container:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Build the image
|
||||||
|
docker build -t kv-tube:latest .
|
||||||
|
|
||||||
|
# Run the container
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
### Building the Image
|
### Building & Tagging for Registry
|
||||||
|
|
||||||
To build the image locally:
|
To build and push to your custom registry:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build -t git.khoavo.myds.me/vndangkhoa/kv-tube:v9 .
|
# Build with your registry and tag
|
||||||
|
docker build -t your-registry.com/kv-tube:latest .
|
||||||
|
|
||||||
|
# Push to registry
|
||||||
|
docker push your-registry.com/kv-tube:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
To build and push to your registry:
|
### Pre-built Image
|
||||||
|
|
||||||
|
If using the pre-built image from Forgejo registry:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build -t git.khoavo.myds.me/vndangkhoa/kv-tube:v9 .
|
# Pull from Forgejo
|
||||||
docker push git.khoavo.myds.me/vndangkhoa/kv-tube:v5
|
docker pull git.khoavo.myds.me/vndangkhoa/kv-tube:v9
|
||||||
|
|
||||||
|
# Or tag as latest for local use
|
||||||
|
docker tag git.khoavo.myds.me/vndangkhoa/kv-tube:v9 kv-tube:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
## Deployment on Synology NAS
|
## Deployment on Synology NAS
|
||||||
|
|
||||||
We recommend using **Container Manager** (DSM 7.2+) or **Docker** (DSM 6/7.1) for a robust and easily manageable deployment.
|
We recommend using **Container Manager** (DSM 7.2+) for the best experience. You can also use **Docker** package (DSM 6/7.1).
|
||||||
|
|
||||||
### 1. Prerequisites
|
### Option 1: Using Container Manager (DSM 7.2+) - Recommended
|
||||||
- **Container Manager** or **Docker** package installed from Package Center.
|
|
||||||
- Ensure ports `5011` (frontend) and `8981` (backend API) are available on your NAS.
|
|
||||||
- Create a folder named `kv-tube` in your `docker` shared folder (e.g., `/volume1/docker/kv-tube`).
|
|
||||||
|
|
||||||
### 2. Using Container Manager (Recommended)
|
#### Step 1: Prepare the folder
|
||||||
|
1. Open **File Station** and navigate to your docker folder (e.g., `/volume1/docker/`)
|
||||||
|
2. Create a new folder named `kv-tube`
|
||||||
|
3. Inside `kv-tube`, create a `data` subfolder
|
||||||
|
|
||||||
1. Open **Container Manager** > **Project** > **Create**.
|
#### Step 2: Upload files
|
||||||
2. Set a Project Name (e.g., `kv-tube`).
|
Upload the following files to `/volume1/docker/kv-tube/`:
|
||||||
3. Set Path to `/volume1/docker/kv-tube`.
|
- `docker-compose.yml`
|
||||||
4. Source: Select **Create docker-compose.yml** and paste the following:
|
- `Dockerfile`
|
||||||
|
- `supervisord.conf`
|
||||||
|
|
||||||
```yaml
|
#### Step 3: Create Project
|
||||||
version: '3.8'
|
1. Open **Container Manager** > **Project** > **Create**
|
||||||
|
2. Project Name: `kv-tube`
|
||||||
|
3. Path: `/volume1/docker/kv-tube`
|
||||||
|
4. Source: Select **docker-compose.yml** (it will auto-detect from the folder)
|
||||||
|
5. Click **Next** > **Done**
|
||||||
|
|
||||||
services:
|
The container will build and start automatically.
|
||||||
kv-tube:
|
|
||||||
image: git.khoavo.myds.me/vndangkhoa/kv-tube:v9
|
|
||||||
container_name: kv-tube
|
|
||||||
platform: linux/amd64
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "5011:3000"
|
|
||||||
- "8981:8080"
|
|
||||||
volumes:
|
|
||||||
- ./data:/app/data
|
|
||||||
environment:
|
|
||||||
- KVTUBE_DATA_DIR=/app/data
|
|
||||||
- GIN_MODE=release
|
|
||||||
- NODE_ENV=production
|
|
||||||
- NEXT_PUBLIC_API_URL=http://127.0.0.1:8080
|
|
||||||
```
|
|
||||||
|
|
||||||
5. Click **Next** until the end and **Done**. The container will build and start automatically.
|
#### Step 4: Access the App
|
||||||
|
|
||||||
### 3. Accessing the App
|
|
||||||
The application will be accessible at:
|
|
||||||
- **Frontend**: `http://<your-nas-ip>:5011`
|
- **Frontend**: `http://<your-nas-ip>:5011`
|
||||||
- **Backend API**: `http://<your-nas-ip>:8981`
|
- **Backend API**: `http://<your-nas-ip>:8981`
|
||||||
- **Mobile Users**: Add to Home Screen via Safari for the full PWA experience with background playback.
|
|
||||||
|
|
||||||
### 4. Volume Permissions (If Needed)
|
---
|
||||||
|
|
||||||
If you encounter permission issues with the data folder, SSH into your NAS and run:
|
### Option 2: Using Docker Package (DSM 6/7.1)
|
||||||
|
|
||||||
|
#### Step 1: Pull the image
|
||||||
|
Open **Docker** > **Registry** and search for `kv-tube`, or use SSH to pull:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Create the data folder with proper permissions
|
docker pull kv-tube:latest
|
||||||
sudo mkdir -p /volume1/docker/kv-tube/data
|
|
||||||
sudo chmod 755 /volume1/docker/kv-tube/data
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5. Updating the Container
|
#### Step 2: Create Container
|
||||||
|
1. Open **Docker** > **Container** > **Create**
|
||||||
|
2. Image: `kv-tube:latest` (or your custom registry URL)
|
||||||
|
3. Container Name: `kv-tube`
|
||||||
|
4. Network: `Bridge`
|
||||||
|
5. Port Forwarding:
|
||||||
|
- Local Port: `5011` → Container Port: `3000`
|
||||||
|
- Local Port: `8981` → Container Port: `8080`
|
||||||
|
6. Volume: Map `/volume1/docker/kv-tube/data` → `/app/data`
|
||||||
|
7. Environment:
|
||||||
|
- `KVTUBE_DATA_DIR=/app/data`
|
||||||
|
- `GIN_MODE=release`
|
||||||
|
- `NODE_ENV=production`
|
||||||
|
8. Restart Policy: `unless-stopped`
|
||||||
|
|
||||||
To update to a new version:
|
#### Step 3: Start Container
|
||||||
|
Click **Create** and then start the container.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Option 3: Using Docker Compose (SSH)
|
||||||
|
|
||||||
|
Connect to your NAS via SSH and run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Pull the latest image
|
# Navigate to your kv-tube folder
|
||||||
docker pull git.khoavo.myds.me/vndangkhoa/kv-tube:v5
|
cd /volume1/docker/kv-tube
|
||||||
|
|
||||||
# Restart the container
|
# Build and start
|
||||||
docker-compose down && docker-compose up -d
|
docker-compose up -d
|
||||||
|
|
||||||
|
# View logs
|
||||||
|
docker-compose logs -f
|
||||||
|
|
||||||
|
# Stop
|
||||||
|
docker-compose down
|
||||||
```
|
```
|
||||||
|
|
||||||
Or use Container Manager's built-in image update feature.
|
---
|
||||||
|
|
||||||
### 6. Troubleshooting
|
### Mobile PWA Installation
|
||||||
|
|
||||||
- **Container won't start**: Check logs via Container Manager or `docker logs kv-tube`
|
For the best mobile experience:
|
||||||
- **Port conflicts**: Ensure ports 5011 and 8080 are not used by other services
|
1. Open `http://<your-nas-ip>:5011` in Safari (iOS) or Chrome (Android)
|
||||||
- **Permission denied**: Check the data folder permissions on your NAS
|
2. Tap **Share** > **Add to Home Screen** (iOS)
|
||||||
- **Slow playback**: Try lowering video quality or ensure sufficient network bandwidth
|
3. Or tap **Install** (Android)
|
||||||
|
|
||||||
|
This gives you a native app-like experience with background audio playback.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Updating the Container
|
||||||
|
|
||||||
|
**Using Container Manager:**
|
||||||
|
1. Stop the container
|
||||||
|
2. Remove the image
|
||||||
|
3. Pull new image or rebuild
|
||||||
|
4. Start the container
|
||||||
|
|
||||||
|
**Using Docker Compose:**
|
||||||
|
```bash
|
||||||
|
cd /volume1/docker/kv-tube
|
||||||
|
docker-compose pull
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
**Using Watchtower (auto-update):**
|
||||||
|
The container label enables Watchtower for automatic updates:
|
||||||
|
```bash
|
||||||
|
docker run --detach \
|
||||||
|
--name watchtower \
|
||||||
|
--volume /var/run/docker.sock:/var/run/docker.sock \
|
||||||
|
--volume /your/path/config:/config \
|
||||||
|
containrrr/watchtower \
|
||||||
|
--include-stopped \
|
||||||
|
--schedule "0 2 * * *" \
|
||||||
|
kv-tube
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Troubleshooting
|
||||||
|
|
||||||
|
| Issue | Solution |
|
||||||
|
|-------|----------|
|
||||||
|
| Container won't start | Check logs: `docker logs kv-tube` or via Container Manager |
|
||||||
|
| Port conflicts | Ensure ports 5011 and 8981 are not used by other services |
|
||||||
|
| Permission denied | SSH to NAS: `sudo chmod -R 755 /volume1/docker/kv-tube/data` |
|
||||||
|
| Slow playback | Lower video quality or ensure sufficient network bandwidth |
|
||||||
|
| Cannot access frontend | Check firewall settings on Synology |
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ services:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
args:
|
args:
|
||||||
- NEXT_PUBLIC_API_URL=http://ut.khoavo.myds.me:8981/api
|
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://localhost:8080/api}
|
||||||
image: git.khoavo.myds.me/vndangkhoa/kv-tube:v9
|
image: kv-tube:latest
|
||||||
container_name: kv-tube
|
container_name: kv-tube
|
||||||
platform: linux/amd64
|
platform: linux/amd64
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
@ -23,6 +23,6 @@ services:
|
||||||
- KVTUBE_DATA_DIR=/app/data
|
- KVTUBE_DATA_DIR=/app/data
|
||||||
- GIN_MODE=release
|
- GIN_MODE=release
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- CORS_ALLOWED_ORIGINS=https://ut.khoavo.myds.me,http://ut.khoavo.myds.me:5011,http://localhost:3000,http://127.0.0.1:3000
|
- CORS_ALLOWED_ORIGINS=*
|
||||||
labels:
|
labels:
|
||||||
- "com.centurylinklabs.watchtower.enable=true"
|
- "com.centurylinklabs.watchtower.enable=true"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ stdout_logfile=/dev/stdout
|
||||||
stdout_logfile_maxbytes=0
|
stdout_logfile_maxbytes=0
|
||||||
stderr_logfile=/dev/stderr
|
stderr_logfile=/dev/stderr
|
||||||
stderr_logfile_maxbytes=0
|
stderr_logfile_maxbytes=0
|
||||||
environment=KVTUBE_DATA_DIR="/app/data",GIN_MODE="release",PORT="8080",CORS_ALLOWED_ORIGINS="https://ut.khoavo.myds.me,http://ut.khoavo.myds.me:5011,http://localhost:3000,http://127.0.0.1:3000"
|
environment=KVTUBE_DATA_DIR="/app/data",GIN_MODE="release",PORT="8080",CORS_ALLOWED_ORIGINS="*"
|
||||||
|
|
||||||
[program:frontend]
|
[program:frontend]
|
||||||
command=node server.js
|
command=node server.js
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue