208 lines
4.6 KiB
Markdown
208 lines
4.6 KiB
Markdown
# Docker Hub Deployment Guide
|
|
|
|
This guide will help you publish the StreamFlow Docker image to Docker Hub so users can easily deploy it.
|
|
|
|
## Prerequisites
|
|
|
|
1. Docker Hub account (create one at https://hub.docker.com)
|
|
2. Docker installed and running locally
|
|
|
|
## Step 1: Login to Docker Hub
|
|
|
|
```bash
|
|
docker login
|
|
```
|
|
|
|
Enter your Docker Hub username and password when prompted.
|
|
|
|
## Step 2: Build the Docker Image
|
|
|
|
Build the image with your Docker Hub username:
|
|
|
|
```bash
|
|
docker build -t aiulian25/streamflow:latest .
|
|
```
|
|
|
|
You can also create version tags:
|
|
|
|
```bash
|
|
docker build -t aiulian25/streamflow:latest -t aiulian25/streamflow:v1.0.0 .
|
|
```
|
|
|
|
## Step 3: Push to Docker Hub
|
|
|
|
Push the image to Docker Hub:
|
|
|
|
```bash
|
|
docker push aiulian25/streamflow:latest
|
|
```
|
|
|
|
If you created version tags, push them too:
|
|
|
|
```bash
|
|
docker push aiulian25/streamflow:v1.0.0
|
|
```
|
|
|
|
## Step 4: Verify on Docker Hub
|
|
|
|
Visit https://hub.docker.com/r/aiulian25/streamflow to verify your image is published.
|
|
|
|
## Automated Build (Optional)
|
|
|
|
You can set up GitHub Actions to automatically build and push images:
|
|
|
|
### Create `.github/workflows/docker-publish.yml`:
|
|
|
|
```yaml
|
|
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
DOCKER_HUB_USERNAME: aiulian25
|
|
IMAGE_NAME: streamflow
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.DOCKER_HUB_USERNAME }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
```
|
|
|
|
### Add Docker Hub Secrets to GitHub:
|
|
|
|
1. Go to your repository: https://github.com/aiulian25/streamflow
|
|
2. Navigate to **Settings** → **Secrets and variables** → **Actions**
|
|
3. Add the following secrets:
|
|
- `DOCKER_HUB_USERNAME`: Your Docker Hub username (aiulian25)
|
|
- `DOCKER_HUB_TOKEN`: Create a token at https://hub.docker.com/settings/security
|
|
|
|
## Usage for End Users
|
|
|
|
After publishing, users can simply run:
|
|
|
|
```bash
|
|
# Download the docker-compose.yml
|
|
wget https://raw.githubusercontent.com/aiulian25/streamflow/main/docker-compose.yml
|
|
|
|
# Create environment file (optional)
|
|
cat > .env <<EOF
|
|
JWT_SECRET=$(openssl rand -base64 32)
|
|
SESSION_SECRET=$(openssl rand -base64 32)
|
|
ENABLE_GPU=false
|
|
EOF
|
|
|
|
# Start the application
|
|
docker compose up -d
|
|
```
|
|
|
|
## Multi-Architecture Support (Optional)
|
|
|
|
To support multiple architectures (amd64, arm64):
|
|
|
|
```bash
|
|
# Create and use a new builder
|
|
docker buildx create --name mybuilder --use
|
|
docker buildx inspect --bootstrap
|
|
|
|
# Build and push for multiple platforms
|
|
docker buildx build --platform linux/amd64,linux/arm64 \
|
|
-t aiulian25/streamflow:latest \
|
|
-t aiulian25/streamflow:v1.0.0 \
|
|
--push .
|
|
```
|
|
|
|
## Quick Commands Reference
|
|
|
|
```bash
|
|
# Build image
|
|
docker build -t aiulian25/streamflow:latest .
|
|
|
|
# Push image
|
|
docker push aiulian25/streamflow:latest
|
|
|
|
# Test locally
|
|
docker run -d -p 12345:12345 -p 9000:9000 aiulian25/streamflow:latest
|
|
|
|
# Check running container
|
|
docker ps
|
|
|
|
# View logs
|
|
docker logs streamflow
|
|
```
|
|
|
|
## Image Size Optimization
|
|
|
|
The current Dockerfile is already optimized with:
|
|
- Multi-stage builds
|
|
- Minimal base image (node:20-slim)
|
|
- Cleaned apt caches
|
|
- Only production dependencies
|
|
|
|
Current estimated size: ~1.5GB (due to ffmpeg, streamlink, yt-dlp requirements)
|
|
|
|
## Updating the Image
|
|
|
|
When you make changes:
|
|
|
|
1. Build with new version tag:
|
|
```bash
|
|
docker build -t aiulian25/streamflow:v1.0.1 -t aiulian25/streamflow:latest .
|
|
```
|
|
|
|
2. Push both tags:
|
|
```bash
|
|
docker push aiulian25/streamflow:v1.0.1
|
|
docker push aiulian25/streamflow:latest
|
|
```
|
|
|
|
3. Users can update by pulling the latest:
|
|
```bash
|
|
docker compose pull
|
|
docker compose up -d
|
|
```
|