Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
69 changes: 69 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Dependency directories
node_modules/
.pnp
.pnp.js

# Build output
build/
dist/

# Test and development files
coverage/
test-results/
playwright-report/
blob-report/
playwright/.cache/
__snapshots__/
.eslintcache

# Environment files
.env.local
.env.development.local
.env.test.local
.env.production.local

# Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.vscode/
.idea/
*.swp
*.swo
*~

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Git
.git/
.gitignore

# Development tools
.storybook/
storybook-static/

# Temporary files
.tmp/
.temp/

# Documentation
docs/
README.md
*.md

# CI/CD
.github/

# Other
stats.html
test-results.json
.wrangler/
105 changes: 105 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Docker Setup for AllKaraoke

This directory contains Docker configuration files to build and run the AllKaraoke application in a containerized environment.

## Files

- `Dockerfile` - Main Docker image definition
- `.dockerignore` - Files to exclude from Docker build context
- `docker-build.sh` - Build script that reads Node version from .nvmrc
- `docker-compose.yml` - Docker Compose configuration for easy development

## Building the Docker Image

### Automatic Build (Recommended)

The build script automatically reads the Node version from `.nvmrc` file:

```bash
./docker-build.sh
```

### Manual Build

You can also build manually with a specific Node version:

```bash
# Build with Node version from .nvmrc (default: 20)
docker build --build-arg NODE_VERSION=20 -t allkaraoke:latest .

# Or build with a different Node version
docker build --build-arg NODE_VERSION=18 -t allkaraoke:latest .
```

## Running the Application

### Using Docker Run

```bash
# Run the container
docker run -p 3010:3010 allkaraoke:latest

# Run with custom environment variables
docker run -p 3010:3010 -e NODE_ENV=production allkaraoke:latest
```

### Using Docker Compose

```bash
# Start the application
docker-compose up

# Start in detached mode
docker-compose up -d

# Build and start
docker-compose up --build
```

## Configuration

### Environment Variables

You can set the Node version when building with Docker Compose:

```bash
NODE_VERSION=18 docker-compose up --build
```

### Port Configuration

The application runs on port 3010 inside the container. You can map it to a different host port:

```bash
docker run -p 8080:3010 allkaraoke:latest
```

## Development

For development, you might want to mount your source code as a volume:

```bash
docker run -p 3010:3010 -v $(pwd):/app -v /app/node_modules allkaraoke:latest
```

However, for active development, it's recommended to run the application directly using `pnpm start` as described in the main README.

## Health Check

The Docker image includes a health check that verifies the application is responding on port 3010. You can check the health status:

```bash
docker inspect --format='{{.State.Health.Status}}' <container_id>
```

## Build Options

The Docker build process:

1. Uses Node.js from the specified version (default: 20) on Alpine Linux
2. Installs pnpm package manager
3. Installs dependencies using `pnpm install --frozen-lockfile`
4. Builds the application using `FAST_BUILD=1 pnpm exec vite build`
5. Serves the built application using `pnpm start:production`

The `FAST_BUILD=1` environment variable is used to skip the pre-rendering step which requires Playwright browsers, making the Docker build faster and smaller.
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Dockerfile for AllKaraoke
# Uses Node version from .nvmrc file (default: 20)

ARG NODE_VERSION=20
FROM node:${NODE_VERSION}-alpine

# Set working directory
WORKDIR /app

# Install pnpm
RUN npm install -g pnpm@9.0.6

# Copy package files first for better layer caching
COPY package.json pnpm-lock.yaml* ./

# Install dependencies
RUN pnpm install --frozen-lockfile

# Copy source code
COPY . .

# Build the application
ENV FAST_BUILD=1
RUN pnpm exec vite build

# Expose port
EXPOSE 3010

# Start the application
CMD ["pnpm", "start:production"]
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ pnpm install
pnpm start
```

### Docker Setup

If you prefer to use Docker, see [DOCKER.md](./DOCKER.md) for complete instructions. Quick start:

```bash
# Build and run with Docker
./docker-build.sh
docker run -p 3010:3010 allkaraoke:latest

# Or use Docker Compose
docker-compose up
```

#### Run in offline mode

Plays dummy local video instead of YouTube to work properly in offline environments (eg. planes).
Expand Down
20 changes: 20 additions & 0 deletions docker-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Build script for AllKaraoke Docker image
# Reads Node version from .nvmrc file

# Read Node version from .nvmrc file
if [ -f ".nvmrc" ]; then
NODE_VERSION=$(cat .nvmrc)
echo "Using Node version from .nvmrc: $NODE_VERSION"
else
NODE_VERSION="20"
echo "No .nvmrc file found, using default Node version: $NODE_VERSION"
fi

# Build the Docker image with the specified Node version
echo "Building Docker image with Node $NODE_VERSION..."
docker build --build-arg NODE_VERSION=$NODE_VERSION -t allkaraoke:latest .

echo "Build complete! You can run the image with:"
echo "docker run -p 3010:3010 allkaraoke:latest"
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3.8'

services:
allkaraoke:
build:
context: .
dockerfile: Dockerfile
args:
NODE_VERSION: "${NODE_VERSION:-20}"
ports:
- "3010:3010"
environment:
- NODE_ENV=production
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3010/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
59 changes: 59 additions & 0 deletions docker-demo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Demo script showing Docker usage for AllKaraoke
# This script demonstrates how the Docker setup works

echo "=== AllKaraoke Docker Setup Demo ==="
echo

# Check Node version from .nvmrc
if [ -f ".nvmrc" ]; then
NODE_VERSION=$(cat .nvmrc)
echo "πŸ“‹ Node version from .nvmrc: $NODE_VERSION"
else
echo "❌ .nvmrc file not found"
exit 1
fi

echo "πŸ“¦ Available Docker commands:"
echo

echo "1. Build Docker image with automatic Node version detection:"
echo " ./docker-build.sh"
echo

echo "2. Build with specific Node version:"
echo " docker build --build-arg NODE_VERSION=$NODE_VERSION -t allkaraoke:latest ."
echo

echo "3. Run the container:"
echo " docker run -p 3010:3010 allkaraoke:latest"
echo

echo "4. Use Docker Compose:"
echo " docker-compose up"
echo

echo "5. Use Docker Compose with specific Node version:"
echo " NODE_VERSION=$NODE_VERSION docker-compose up --build"
echo

echo "πŸš€ The application will be available at: http://localhost:3010"
echo

echo "πŸ“š For detailed instructions, see DOCKER.md"
echo

# Show what the build process does
echo "=== Build Process Overview ==="
echo "1. 🐳 Starts with node:$NODE_VERSION-alpine base image"
echo "2. πŸ“¦ Installs pnpm package manager"
echo "3. πŸ“₯ Copies package.json and pnpm-lock.yaml"
echo "4. ⬇️ Installs dependencies with pnpm install --frozen-lockfile"
echo "5. πŸ“ Copies source code"
echo "6. πŸ”¨ Builds app with FAST_BUILD=1 pnpm exec vite build"
echo "7. πŸš€ Starts production server with pnpm start:production"
echo "8. 🌐 Exposes port 3010"
echo

echo "βœ… Docker setup complete and ready to use!"
Loading