mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-12-23 23:59:04 -05:00
Added Docker-based development environment
This commit is contained in:
56
dev-setup/.dockerignore
Normal file
56
dev-setup/.dockerignore
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# Git files
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.github
|
||||||
|
|
||||||
|
# Development data
|
||||||
|
data/
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
*.md
|
||||||
|
docs/
|
||||||
|
screenshot/
|
||||||
|
|
||||||
|
# Test files
|
||||||
|
tests/
|
||||||
|
*_test.py
|
||||||
|
*.test.js
|
||||||
|
|
||||||
|
# Cache and temporary files
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
*.pyd
|
||||||
|
.Python
|
||||||
|
*.so
|
||||||
|
.cache/
|
||||||
|
.pytest_cache/
|
||||||
|
.coverage
|
||||||
|
htmlcov/
|
||||||
|
|
||||||
|
# Node modules (for frontend, will be installed in container)
|
||||||
|
node_modules/
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# IDE files
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
|
||||||
|
# OS files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Build artifacts
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
*.egg-info/
|
||||||
|
|
||||||
|
# Docker files
|
||||||
|
Dockerfile*
|
||||||
|
docker-compose*.yml
|
||||||
|
.dockerignore
|
||||||
6
dev-setup/.gitignore
vendored
Normal file
6
dev-setup/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Development data directory
|
||||||
|
data/
|
||||||
|
|
||||||
|
# Docker volumes and temporary files
|
||||||
|
.env
|
||||||
|
*.log
|
||||||
61
dev-setup/Dockerfile.backend
Normal file
61
dev-setup/Dockerfile.backend
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
FROM alpine:3.22
|
||||||
|
|
||||||
|
# Install build dependencies and runtime dependencies
|
||||||
|
RUN \
|
||||||
|
apk add --no-cache --virtual=build-dependencies \
|
||||||
|
build-base \
|
||||||
|
cargo \
|
||||||
|
libffi-dev \
|
||||||
|
libpq-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
libxslt-dev \
|
||||||
|
python3-dev && \
|
||||||
|
apk add --no-cache \
|
||||||
|
ffmpeg \
|
||||||
|
libxml2 \
|
||||||
|
libxslt \
|
||||||
|
mediainfo \
|
||||||
|
python3 \
|
||||||
|
py3-pip \
|
||||||
|
p7zip \
|
||||||
|
bash \
|
||||||
|
git && \
|
||||||
|
mkdir -p \
|
||||||
|
/app/bazarr/bin \
|
||||||
|
/app/bazarr/data/config \
|
||||||
|
/app/bazarr/data/cache \
|
||||||
|
/app/bazarr/data/log
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /app/bazarr/bin
|
||||||
|
|
||||||
|
# Copy only backend-related files
|
||||||
|
COPY requirements.txt postgres-requirements.txt dev-requirements.txt ./
|
||||||
|
COPY bazarr.py ./
|
||||||
|
COPY libs ./libs
|
||||||
|
COPY custom_libs ./custom_libs
|
||||||
|
COPY bazarr ./bazarr
|
||||||
|
COPY migrations ./migrations
|
||||||
|
|
||||||
|
# Install Python dependencies
|
||||||
|
RUN \
|
||||||
|
pip install --break-system-packages -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.22/ \
|
||||||
|
-r requirements.txt \
|
||||||
|
-r postgres-requirements.txt \
|
||||||
|
-r dev-requirements.txt
|
||||||
|
|
||||||
|
# Clean up build dependencies
|
||||||
|
RUN apk del build-dependencies
|
||||||
|
|
||||||
|
# Expose backend port
|
||||||
|
EXPOSE 6767
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
ENV SZ_USER_AGENT="bazarr-dev"
|
||||||
|
ENV BAZARR_VERSION="dev"
|
||||||
|
# Using PYTHONPATH instead of symlinks for cleaner approach
|
||||||
|
# The order matters: custom_libs first (to override libs), then libs, then bazarr directory
|
||||||
|
ENV PYTHONPATH="/app/bazarr/bin/custom_libs:/app/bazarr/bin/libs:/app/bazarr/bin/bazarr:/app/bazarr/bin"
|
||||||
|
|
||||||
|
# Default command
|
||||||
|
CMD ["python3", "bazarr.py", "--debug", "--no-update", "--config", "/app/bazarr/data"]
|
||||||
40
dev-setup/Dockerfile.frontend
Normal file
40
dev-setup/Dockerfile.frontend
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
ARG NODE_VERSION=20
|
||||||
|
|
||||||
|
FROM node:${NODE_VERSION}-alpine
|
||||||
|
|
||||||
|
# Install wget for healthcheck
|
||||||
|
RUN apk add --no-cache wget
|
||||||
|
|
||||||
|
# Use development node environment by default
|
||||||
|
ENV NODE_ENV=development
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy package files first for better caching
|
||||||
|
COPY frontend/package.json frontend/package-lock.json ./
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# Copy frontend source files (these will be overridden by volume mounts in dev)
|
||||||
|
COPY frontend/ .
|
||||||
|
|
||||||
|
# Copy and setup entrypoint script
|
||||||
|
COPY dev-setup/frontend-entrypoint.sh /usr/local/bin/
|
||||||
|
RUN chmod +x /usr/local/bin/frontend-entrypoint.sh
|
||||||
|
|
||||||
|
# Change ownership of the /app directory to the node user
|
||||||
|
RUN chown -R node:node /app
|
||||||
|
|
||||||
|
# Switch to the node user for security
|
||||||
|
USER node
|
||||||
|
|
||||||
|
# Ensure node_modules/.bin is in the PATH
|
||||||
|
ENV PATH=/app/node_modules/.bin:$PATH
|
||||||
|
|
||||||
|
# Expose the Vite dev server port
|
||||||
|
EXPOSE 5173
|
||||||
|
|
||||||
|
# Run the development server via entrypoint
|
||||||
|
CMD ["/usr/local/bin/frontend-entrypoint.sh"]
|
||||||
257
dev-setup/README.md
Normal file
257
dev-setup/README.md
Normal file
@@ -0,0 +1,257 @@
|
|||||||
|
# Bazarr Development Environment
|
||||||
|
|
||||||
|
A complete Docker-based development environment for Bazarr with live code reloading for both backend and frontend.
|
||||||
|
|
||||||
|
> **Note**: This is the official Docker development setup for Bazarr. All Docker-related files are centralized here to avoid confusion and ensure consistency.
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
### 1. Clone your fork
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/YOUR_USERNAME/bazarr.git
|
||||||
|
cd bazarr/dev-setup
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Run the setup script
|
||||||
|
```bash
|
||||||
|
./test-setup.sh
|
||||||
|
```
|
||||||
|
This will create the necessary directories and a minimal config file with default credentials for development.
|
||||||
|
|
||||||
|
### 3. Start development environment
|
||||||
|
```bash
|
||||||
|
docker compose up --build
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Access applications
|
||||||
|
**🌐 Open your browser to: http://localhost:5173**
|
||||||
|
|
||||||
|
This is the Bazarr web interface with live reloading. The frontend automatically communicates with the backend API (port 6767).
|
||||||
|
|
||||||
|
**Default credentials:**
|
||||||
|
- Username: `admin`
|
||||||
|
- Password: `admin`
|
||||||
|
|
||||||
|
**Important**:
|
||||||
|
- Port 5173: Frontend development server with hot module replacement
|
||||||
|
- Port 6767: Backend API server (not meant for direct browser access)
|
||||||
|
- API Key: `bazarr` (for API access)
|
||||||
|
|
||||||
|
## What This Provides
|
||||||
|
|
||||||
|
### 🐳 **Fully Containerized Development**
|
||||||
|
- Separate optimized containers for backend (Python/Alpine) and frontend (Node.js)
|
||||||
|
- No need for local Node.js, Python, or other dependencies on your host
|
||||||
|
- Consistent development environment across different machines
|
||||||
|
- Each container only includes necessary dependencies
|
||||||
|
|
||||||
|
### 🔄 **Live Code Reloading**
|
||||||
|
- **Backend**: Python files are mounted and changes reflect immediately
|
||||||
|
- **Frontend**: Full frontend directory mounted with Vite hot module replacement
|
||||||
|
- **Libraries**: Both custom_libs and libs are mounted for modification
|
||||||
|
|
||||||
|
### 📁 **Volume Mounts**
|
||||||
|
```
|
||||||
|
../bazarr → /app/bazarr/bin/bazarr (Backend source)
|
||||||
|
../frontend → /app/bazarr/bin/frontend (Frontend source)
|
||||||
|
../custom_libs → /app/bazarr/bin/custom_libs (Custom libraries)
|
||||||
|
../libs → /app/bazarr/bin/libs (Third-party libraries)
|
||||||
|
./data → /app/bazarr/data (Persistent data)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 🌐 **Port Configuration**
|
||||||
|
- **6767**: Bazarr backend API and web interface
|
||||||
|
- **5173**: Vite development server with hot reloading
|
||||||
|
|
||||||
|
## Development Workflow
|
||||||
|
|
||||||
|
### Making Changes
|
||||||
|
|
||||||
|
1. **Backend Development**:
|
||||||
|
- Edit files in `../bazarr/` directory
|
||||||
|
- Changes are immediately available in the running container
|
||||||
|
- No restart needed for most Python changes
|
||||||
|
|
||||||
|
2. **Frontend Development**:
|
||||||
|
- Edit files in `../frontend/` directory
|
||||||
|
- Vite automatically reloads the browser
|
||||||
|
- Install new npm packages by rebuilding: `docker compose up --build`
|
||||||
|
|
||||||
|
3. **Adding Dependencies**:
|
||||||
|
- **Python**: Add to `../requirements.txt` and rebuild
|
||||||
|
- **Node.js**: Add to `../frontend/package.json` and rebuild
|
||||||
|
|
||||||
|
### Useful Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Start development environment
|
||||||
|
docker compose up
|
||||||
|
|
||||||
|
# Start in background (detached)
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# Rebuild after dependency changes
|
||||||
|
docker compose up --build
|
||||||
|
|
||||||
|
# View logs
|
||||||
|
docker compose logs -f
|
||||||
|
|
||||||
|
# Access backend container shell for debugging
|
||||||
|
docker compose exec bazarr-backend sh
|
||||||
|
|
||||||
|
# Access frontend container shell for debugging
|
||||||
|
docker compose exec bazarr-frontend sh
|
||||||
|
|
||||||
|
# Stop the environment
|
||||||
|
docker compose down
|
||||||
|
|
||||||
|
# Complete cleanup (removes containers, networks, volumes)
|
||||||
|
docker compose down -v
|
||||||
|
```
|
||||||
|
|
||||||
|
## Environment Configuration
|
||||||
|
|
||||||
|
The development environment includes these settings:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
NODE_ENV=development
|
||||||
|
VITE_PROXY_URL=http://127.0.0.1:6767
|
||||||
|
VITE_BAZARR_CONFIG_FILE=/app/bazarr/data/config/config.yaml
|
||||||
|
VITE_CAN_UPDATE=true
|
||||||
|
VITE_HAS_UPDATE=false
|
||||||
|
VITE_REACT_QUERY_DEVTOOLS=true
|
||||||
|
```
|
||||||
|
|
||||||
|
## Data Persistence
|
||||||
|
|
||||||
|
Configuration and data are persisted in the `./data` directory:
|
||||||
|
- `./data/config/` - Bazarr configuration files
|
||||||
|
- `./data/cache/` - Application cache
|
||||||
|
- `./data/log/` - Application logs
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Port Conflicts
|
||||||
|
If ports 6767 or 5173 are already in use:
|
||||||
|
```bash
|
||||||
|
# Check what's using the ports
|
||||||
|
lsof -i :6767
|
||||||
|
lsof -i :5173
|
||||||
|
|
||||||
|
# Either stop those services or modify ports in docker-compose.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
### Permission Issues
|
||||||
|
```bash
|
||||||
|
# Fix data directory permissions
|
||||||
|
sudo chown -R $USER:$USER ./data
|
||||||
|
```
|
||||||
|
|
||||||
|
### Frontend Not Loading
|
||||||
|
- Check frontend logs: `docker compose logs -f bazarr-frontend`
|
||||||
|
- Ensure Vite dev server started successfully
|
||||||
|
- Try rebuilding frontend: `docker compose up --build bazarr-frontend`
|
||||||
|
|
||||||
|
### Backend API Issues
|
||||||
|
- Verify backend is running: `docker compose logs bazarr-backend`
|
||||||
|
|
||||||
|
### Authentication/Login Issues
|
||||||
|
If you're prompted for a password:
|
||||||
|
1. The default credentials are: **admin/admin**
|
||||||
|
2. Check if `data/config/config.yaml` exists with proper auth settings
|
||||||
|
3. If not, run `./test-setup.sh` to create the proper config
|
||||||
|
4. Restart the containers: `docker compose restart`
|
||||||
|
5. The API key is set to: **bazarr**
|
||||||
|
|
||||||
|
If you still have issues:
|
||||||
|
- Delete the data directory: `rm -rf data/`
|
||||||
|
- Run the setup script: `./test-setup.sh`
|
||||||
|
- Rebuild and start: `docker compose up --build`
|
||||||
|
- Check if port 6767 is accessible: `curl http://localhost:6767`
|
||||||
|
- Review Python error logs in the backend container output
|
||||||
|
|
||||||
|
### Complete Reset
|
||||||
|
If you encounter persistent issues:
|
||||||
|
```bash
|
||||||
|
# Stop and remove everything
|
||||||
|
docker compose down -v
|
||||||
|
|
||||||
|
# Remove built images
|
||||||
|
docker rmi dev-setup-bazarr-backend dev-setup-bazarr-frontend
|
||||||
|
|
||||||
|
# Rebuild from scratch
|
||||||
|
docker compose up --build
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development Tips
|
||||||
|
|
||||||
|
### Container Shell Access
|
||||||
|
```bash
|
||||||
|
# Access the backend container
|
||||||
|
docker compose exec bazarr-backend sh
|
||||||
|
|
||||||
|
# Access the frontend container
|
||||||
|
docker compose exec bazarr-frontend sh
|
||||||
|
|
||||||
|
# Install additional tools inside backend container if needed
|
||||||
|
docker compose exec bazarr-backend apk add --no-cache curl vim
|
||||||
|
|
||||||
|
# Install additional tools inside frontend container if needed
|
||||||
|
docker compose exec bazarr-frontend apk add --no-cache curl vim
|
||||||
|
```
|
||||||
|
|
||||||
|
### Logs and Debugging
|
||||||
|
```bash
|
||||||
|
# Follow all logs
|
||||||
|
docker compose logs -f
|
||||||
|
|
||||||
|
# Follow only backend logs
|
||||||
|
docker compose logs -f bazarr-backend
|
||||||
|
|
||||||
|
# Follow only frontend logs
|
||||||
|
docker compose logs -f bazarr-frontend
|
||||||
|
```
|
||||||
|
|
||||||
|
### Performance
|
||||||
|
- Separate containers for frontend and backend for better resource utilization
|
||||||
|
- Backend uses lightweight Alpine Linux with Python
|
||||||
|
- Frontend uses optimized Node.js Alpine image
|
||||||
|
- All file changes are immediately reflected due to volume mounts
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
```
|
||||||
|
Host Machine
|
||||||
|
├── bazarr/ (your code)
|
||||||
|
│ ├── bazarr/ → mounted in backend container
|
||||||
|
│ ├── frontend/ → mounted in frontend container
|
||||||
|
│ ├── custom_libs/ → mounted in backend container
|
||||||
|
│ └── libs/ → mounted in backend container
|
||||||
|
└── dev-setup/ (all dev environment files in one place)
|
||||||
|
├── data/ → persistent data
|
||||||
|
├── Dockerfile.backend → Python/Alpine backend image
|
||||||
|
├── Dockerfile.frontend → Node.js frontend image (dev-optimized)
|
||||||
|
├── docker-compose.yml → Orchestration config
|
||||||
|
├── test-setup.sh → Setup validation script
|
||||||
|
└── README.md
|
||||||
|
|
||||||
|
Backend Container (/app/bazarr/bin/)
|
||||||
|
├── bazarr/ (backend source - mounted)
|
||||||
|
├── custom_libs/ (mounted)
|
||||||
|
├── libs/ (mounted)
|
||||||
|
└── data/ (persistent data - mounted)
|
||||||
|
|
||||||
|
Frontend Container (/app/)
|
||||||
|
├── src/ (frontend source - mounted)
|
||||||
|
├── public/ (static assets - mounted)
|
||||||
|
├── config/ (configuration - mounted)
|
||||||
|
└── node_modules/ (npm packages - container only)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Next Steps
|
||||||
|
|
||||||
|
1. Start developing - all changes are live!
|
||||||
|
2. Test your modifications at http://localhost:6767 and http://localhost:5173
|
||||||
|
3. Submit pull requests to the main repository
|
||||||
|
|
||||||
|
Happy coding! 🚀
|
||||||
81
dev-setup/docker-compose.yml
Normal file
81
dev-setup/docker-compose.yml
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
services:
|
||||||
|
bazarr-backend:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: dev-setup/Dockerfile.backend
|
||||||
|
container_name: bazarr-backend
|
||||||
|
ports:
|
||||||
|
- "6767:6767" # Bazarr backend API
|
||||||
|
volumes:
|
||||||
|
# Mount source code for live editing
|
||||||
|
- ../bazarr.py:/app/bazarr/bin/bazarr.py:ro
|
||||||
|
- ../bazarr:/app/bazarr/bin/bazarr:ro
|
||||||
|
- ../custom_libs:/app/bazarr/bin/custom_libs:ro
|
||||||
|
- ../libs:/app/bazarr/bin/libs:ro
|
||||||
|
- ../migrations:/app/bazarr/bin/migrations:ro
|
||||||
|
|
||||||
|
# Mount data directory for persistence
|
||||||
|
- ./data:/app/bazarr/data
|
||||||
|
environment:
|
||||||
|
- SZ_USER_AGENT=bazarr-dev
|
||||||
|
- BAZARR_VERSION=dev
|
||||||
|
- PYTHONPATH=/app/bazarr/bin/custom_libs:/app/bazarr/bin/libs:/app/bazarr/bin/bazarr:/app/bazarr/bin
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- bazarr-network
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-z", "localhost", "6767"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 20
|
||||||
|
start_period: 30s
|
||||||
|
|
||||||
|
bazarr-frontend:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: dev-setup/Dockerfile.frontend
|
||||||
|
container_name: bazarr-frontend
|
||||||
|
ports:
|
||||||
|
- "5173:5173" # Vite frontend dev server
|
||||||
|
volumes:
|
||||||
|
# Mount frontend source code for live editing
|
||||||
|
- ../frontend/src:/app/src:ro
|
||||||
|
- ../frontend/public:/app/public:ro
|
||||||
|
- ../frontend/config:/app/config:ro
|
||||||
|
- ../frontend/vite.config.ts:/app/vite.config.ts:ro
|
||||||
|
- ../frontend/tsconfig.json:/app/tsconfig.json:ro
|
||||||
|
- ../frontend/package.json:/app/package.json:ro
|
||||||
|
- ../frontend/.env.development:/app/.env.development:ro
|
||||||
|
|
||||||
|
# Ensure node_modules is not overwritten by volume mount
|
||||||
|
- /app/node_modules
|
||||||
|
|
||||||
|
# Share data directory so frontend can read backend config
|
||||||
|
- ./data:/app/data
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=development
|
||||||
|
- VITE_PROXY_URL=http://bazarr-backend:6767
|
||||||
|
- VITE_BAZARR_CONFIG_FILE=/app/data/config/config.yaml
|
||||||
|
- VITE_CAN_UPDATE=true
|
||||||
|
- VITE_HAS_UPDATE=false
|
||||||
|
- VITE_REACT_QUERY_DEVTOOLS=true
|
||||||
|
- VITE_API_KEY=bazarr # Set the API key to match config
|
||||||
|
depends_on:
|
||||||
|
- bazarr-backend
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- bazarr-network
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "nc", "-z", "bazarr-backend", "6767"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 30
|
||||||
|
start_period: 60s
|
||||||
|
|
||||||
|
networks:
|
||||||
|
bazarr-network:
|
||||||
|
driver: bridge
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
bazarr-dev-data:
|
||||||
|
driver: local
|
||||||
17
dev-setup/frontend-entrypoint.sh
Normal file
17
dev-setup/frontend-entrypoint.sh
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "Waiting for backend to be ready..."
|
||||||
|
|
||||||
|
# Wait for backend to be reachable
|
||||||
|
until nc -z bazarr-backend 6767 2>/dev/null; do
|
||||||
|
echo "Backend not ready yet, waiting..."
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Backend is ready!"
|
||||||
|
|
||||||
|
# In development mode, we don't need to wait for API key since authentication might be disabled
|
||||||
|
echo "Starting frontend in development mode..."
|
||||||
|
|
||||||
|
# Start the frontend with --no-open to prevent browser auto-open attempts in container
|
||||||
|
exec npm run start -- --host --no-open
|
||||||
75
dev-setup/test-setup.sh
Executable file
75
dev-setup/test-setup.sh
Executable file
@@ -0,0 +1,75 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Testing Bazarr Development Setup..."
|
||||||
|
echo "=================================="
|
||||||
|
|
||||||
|
# Check if Docker is installed
|
||||||
|
if ! command -v docker &> /dev/null; then
|
||||||
|
echo "❌ Docker is not installed. Please install Docker first."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if Docker Compose is installed
|
||||||
|
if ! command -v docker compose &> /dev/null; then
|
||||||
|
echo "❌ Docker Compose is not installed. Please install Docker Compose first."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✅ Docker and Docker Compose are installed"
|
||||||
|
|
||||||
|
# Check if data directory exists
|
||||||
|
if [ ! -d "./data" ]; then
|
||||||
|
echo "📁 Creating data directory..."
|
||||||
|
mkdir -p data/config data/cache data/log data/db
|
||||||
|
else
|
||||||
|
echo "📁 Data directory exists, ensuring subdirectories..."
|
||||||
|
mkdir -p data/config data/cache data/log data/db
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✅ Data directory is ready"
|
||||||
|
|
||||||
|
# Create a minimal config for development if it doesn't exist
|
||||||
|
if [ ! -f "./data/config/config.yaml" ]; then
|
||||||
|
echo "📝 Creating minimal config.yaml for development..."
|
||||||
|
# The password needs to be stored as MD5 hash
|
||||||
|
# MD5 hash of "admin" is: 21232f297a57a5a743894a0e4a801fc3
|
||||||
|
cat > data/config/config.yaml << 'EOF'
|
||||||
|
auth:
|
||||||
|
type: form
|
||||||
|
apikey: 'bazarr'
|
||||||
|
username: 'admin'
|
||||||
|
password: '21232f297a57a5a743894a0e4a801fc3'
|
||||||
|
|
||||||
|
general:
|
||||||
|
port: 6767
|
||||||
|
base_url: ''
|
||||||
|
EOF
|
||||||
|
echo "✅ Config file created with default credentials (admin/admin)"
|
||||||
|
else
|
||||||
|
echo "✅ Config file already exists"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if both services are defined
|
||||||
|
if docker compose config --services | grep -q "bazarr-backend" && docker compose config --services | grep -q "bazarr-frontend"; then
|
||||||
|
echo "✅ Both services (backend and frontend) are properly configured"
|
||||||
|
else
|
||||||
|
echo "❌ Services are not properly configured in docker-compose.yml"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Validate the compose file
|
||||||
|
if docker compose config > /dev/null 2>&1; then
|
||||||
|
echo "✅ docker-compose.yml is valid"
|
||||||
|
else
|
||||||
|
echo "❌ docker-compose.yml has errors"
|
||||||
|
docker compose config
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "🎉 Everything looks good! You can now run:"
|
||||||
|
echo " docker compose up --build"
|
||||||
|
echo ""
|
||||||
|
echo "Once started:"
|
||||||
|
echo " - Frontend will be available at: http://localhost:5173"
|
||||||
|
echo " - Backend API will be available at: http://localhost:6767"
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
ARG NODE_VERSION=20
|
|
||||||
|
|
||||||
FROM node:${NODE_VERSION}-alpine
|
|
||||||
|
|
||||||
# Use development node environment by default.
|
|
||||||
ENV NODE_ENV development
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy package.json and package-lock.json to the working directory
|
|
||||||
COPY package.json package-lock.json ./
|
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
# Copy the rest of the source files into the image
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# Change ownership of the /app directory to the node user
|
|
||||||
RUN chown -R node:node /app
|
|
||||||
|
|
||||||
# Switch to the node user
|
|
||||||
USER node
|
|
||||||
|
|
||||||
# Ensure node_modules/.bin is in the PATH
|
|
||||||
ENV PATH /app/node_modules/.bin:$PATH
|
|
||||||
|
|
||||||
# Expose the port that the application listens on
|
|
||||||
EXPOSE 5173
|
|
||||||
|
|
||||||
# Run the application
|
|
||||||
CMD ["npm", "start"]
|
|
||||||
@@ -58,31 +58,24 @@
|
|||||||
|
|
||||||
## Building with Docker
|
## Building with Docker
|
||||||
|
|
||||||
You can now build and run the frontend using Docker. Follow these steps:
|
For Docker-based development, please use the comprehensive development environment provided in the `dev-setup` folder:
|
||||||
|
|
||||||
### Benefits of Using Docker
|
```bash
|
||||||
|
cd ../dev-setup
|
||||||
|
docker compose up --build
|
||||||
|
```
|
||||||
|
|
||||||
- **Consistency**: Ensures the app runs in the same environment across all systems.
|
This will start both the backend and frontend in separate optimized containers with live reloading enabled.
|
||||||
- **Isolation**: Avoids dependency conflicts with other projects on your machine.
|
|
||||||
- **Ease of Deployment**: Simplifies the process of deploying the app to production.
|
|
||||||
|
|
||||||
### Steps to Build and Run
|
### Benefits of the dev-setup Docker Environment
|
||||||
|
|
||||||
1. Build the Docker image with the Node.js version specified in `.nvmrc`:
|
- **Full Stack**: Runs both backend and frontend with proper networking
|
||||||
|
- **Live Reloading**: Changes to your code are immediately reflected
|
||||||
|
- **Consistency**: Ensures the app runs in the same environment across all systems
|
||||||
|
- **Isolation**: Avoids dependency conflicts with other projects on your machine
|
||||||
|
- **Optimized**: Separate containers for backend (Python/Alpine) and frontend (Node.js)
|
||||||
|
|
||||||
```
|
For more details, see the [dev-setup README](../dev-setup/README.md).
|
||||||
$ docker build --build-arg NODE_VERSION=$(cat .nvmrc 2>/dev/null || echo "20") -t your-image-name .
|
|
||||||
```
|
|
||||||
|
|
||||||
- The `docker build --build-arg NODE_VERSION=$(cat .nvmrc 2>/dev/null || echo "20") -t your-image-name .` argument ensures the Docker image uses the Node.js version specified in the `.nvmrc` file.
|
|
||||||
|
|
||||||
2. Run the Docker container:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ docker run -p 5173:5173 your-image-name
|
|
||||||
```
|
|
||||||
|
|
||||||
- Add `.env.development.local` with the path to your environment file if needed.
|
|
||||||
|
|
||||||
3. Open the app in your browser at `http://localhost:5173`.
|
3. Open the app in your browser at `http://localhost:5173`.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user