docs: Update deployment guide with server deployment option

This commit is contained in:
Peifan Li
2025-03-20 22:19:54 -04:00
parent 02b07431ef
commit 060f4450b4
3 changed files with 67 additions and 30 deletions

View File

@@ -1,11 +1,11 @@
# Deployment Guide for MyTube
This guide explains how to deploy MyTube to a QNAP Container Station.
This guide explains how to deploy MyTube to a server or QNAP Container Station.
## Prerequisites
- Docker Hub account
- QNAP NAS with Container Station installed
- Server with Docker and Docker Compose installed, or QNAP NAS with Container Station installed
- Docker installed on your development machine
## Docker Images
@@ -34,14 +34,47 @@ The script will:
- Build the backend and frontend Docker images optimized for amd64 architecture
- Push the images to Docker Hub under your account (franklioxygen)
### 2. Deploy on QNAP Container Station
### 2. Configure Environment Variables
The docker-compose.yml file uses environment variables that should be set according to your specific deployment environment:
#### a) Setting Environment Variables Directly
Before deploying, you can export the variables in your shell:
```bash
export API_URL=http://your-server-ip:5551/api
export BACKEND_URL=http://your-server-ip:5551
```
#### b) Using .env File
Alternatively, create a `.env` file in the same directory as your docker-compose.yml with the following content:
```
API_URL=http://your-server-ip:5551/api
BACKEND_URL=http://your-server-ip:5551
```
Replace `your-server-ip` with your actual server IP address or hostname.
### 3. Deploy on Server or QNAP Container Station
#### For Generic Server with Docker Compose:
```bash
docker-compose up -d
```
#### For QNAP Container Station:
1. Copy the `docker-compose.yml` file to your QNAP NAS
2. Open Container Station on your QNAP
3. Navigate to the "Applications" tab
4. Click on "Create" and select "Create from YAML"
5. Upload the `docker-compose.yml` file or paste its contents
6. Click "Create" to deploy the application
2. If using the .env approach, copy the .env file as well
3. Open Container Station on your QNAP
4. Navigate to the "Applications" tab
5. Click on "Create" and select "Create from YAML"
6. Upload the `docker-compose.yml` file or paste its contents
7. Click "Create" to deploy the application
#### Volume Paths on QNAP
@@ -53,19 +86,21 @@ volumes:
- /share/CACHEDEV2_DATA/Medias/MyTube/data:/app/data
```
Ensure these directories exist on your QNAP before deployment. If they don't exist, create them:
Ensure these directories exist on your server or QNAP before deployment. If they don't exist, create them:
```bash
mkdir -p /share/CACHEDEV2_DATA/Medias/MyTube/uploads
mkdir -p /share/CACHEDEV2_DATA/Medias/MyTube/data
```
### 3. Access the Application
If deploying to a different server (not QNAP), you may want to modify these paths in the docker-compose.yml file.
### 4. Access the Application
Once deployed:
- Frontend will be accessible at: http://192.168.1.105:5556
- Backend API will be accessible at: http://192.168.1.105:5551/api
- Frontend will be accessible at: http://your-server-ip:5556
- Backend API will be accessible at: http://your-server-ip:5551/api
## Volume Persistence
@@ -85,12 +120,12 @@ The services are connected through a dedicated bridge network called `mytube-net
## Environment Variables
The Docker images have been configured with the following default environment variables:
The Docker images now use configurable environment variables with sensible defaults:
### Frontend
- `VITE_API_URL`: http://192.168.1.105:5551/api
- `VITE_BACKEND_URL`: http://192.168.1.105:5551
- `VITE_API_URL`: Defaults to http://localhost:5551/api if not set
- `VITE_BACKEND_URL`: Defaults to http://localhost:5551 if not set
### Backend
@@ -101,7 +136,8 @@ The Docker images have been configured with the following default environment va
If you encounter issues:
1. Check if the Docker images were successfully pushed to Docker Hub
2. Verify that Container Station has internet access to pull the images
3. Check Container Station logs for any deployment errors
4. Ensure ports 5551 and 5556 are not being used by other services on your QNAP
5. If backend fails with Python-related errors, verify that the container has Python installed
2. Verify that your server or Container Station has internet access to pull the images
3. Check the logs for any deployment errors with `docker-compose logs`
4. Ensure ports 5551 and 5556 are not being used by other services
5. Verify that the environment variables are correctly set
6. If backend fails with Python-related errors, verify that the container has Python installed

View File

@@ -18,12 +18,9 @@ $DOCKER_PATH build --no-cache --platform linux/amd64 -t $BACKEND_IMAGE .
cd ..
# Build frontend image with no-cache to force rebuild
echo "🏗️ Building frontend image with correct environment variables..."
echo "🏗️ Building frontend image..."
cd frontend
$DOCKER_PATH build --no-cache --platform linux/amd64 \
--build-arg VITE_API_URL=http://192.168.1.105:5551/api \
--build-arg VITE_BACKEND_URL=http://192.168.1.105:5551 \
-t $FRONTEND_IMAGE .
$DOCKER_PATH build --no-cache --platform linux/amd64 -t $FRONTEND_IMAGE .
cd ..
# Push images to Docker Hub
@@ -35,7 +32,10 @@ echo "✅ Successfully built and pushed images to Docker Hub!"
echo "Backend image: $BACKEND_IMAGE"
echo "Frontend image: $FRONTEND_IMAGE"
echo ""
echo "To deploy to your QNAP Container Station at 192.168.1.105:"
echo "1. Upload the docker-compose.yml file to your QNAP"
echo "2. Use Container Station to deploy the stack using this compose file"
echo "3. Access your application at http://192.168.1.105:5556"
echo "To deploy to your server or QNAP Container Station:"
echo "1. Upload the docker-compose.yml file to your server"
echo "2. Set environment variables in your docker-compose.yml file:"
echo " - VITE_API_URL=http://your-server-ip:port/api"
echo " - VITE_BACKEND_URL=http://your-server-ip:port"
echo "3. Use Container Station or Docker to deploy the stack using this compose file"
echo "4. Access your application at the configured port"

View File

@@ -23,8 +23,9 @@ services:
ports:
- "5556:5556"
environment:
- VITE_API_URL=http://192.168.1.105:5551/api
- VITE_BACKEND_URL=http://192.168.1.105:5551
# Update these values with your actual server IP/hostname and ports
- VITE_API_URL=${API_URL:-http://localhost:5551/api}
- VITE_BACKEND_URL=${BACKEND_URL:-http://localhost:5551}
depends_on:
- backend
restart: unless-stopped