Add Docker configuration and .dockerignore for Serena application
This commit is contained in:
parent
1485183443
commit
dab720ef1b
4 changed files with 322 additions and 1 deletions
65
.dockerignore
Normal file
65
.dockerignore
Normal file
|
@ -0,0 +1,65 @@
|
|||
# Git
|
||||
.git
|
||||
.gitignore
|
||||
|
||||
# Documentation
|
||||
README.md
|
||||
LICENSE
|
||||
*.md
|
||||
|
||||
# Node modules (will be installed in container)
|
||||
frontend/node_modules
|
||||
node_modules
|
||||
|
||||
# Build artifacts
|
||||
backend/build
|
||||
frontend/build
|
||||
backend/.gradle
|
||||
backend/bin
|
||||
|
||||
# IDE files
|
||||
.vscode
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
# OS files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Environment files
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage/
|
||||
|
||||
# Dependency directories
|
||||
jspm_packages/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
65
Dockerfile
65
Dockerfile
|
@ -0,0 +1,65 @@
|
|||
# Multi-stage Dockerfile for Serena (Backend + Frontend)
|
||||
|
||||
# Stage 1: Build Frontend
|
||||
FROM node:18-alpine AS frontend-builder
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
# Copy package files
|
||||
COPY frontend/package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy frontend source
|
||||
COPY frontend/ ./
|
||||
|
||||
# Build frontend
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Build Backend
|
||||
FROM openjdk:21-jdk-slim AS backend-builder
|
||||
|
||||
WORKDIR /app/backend
|
||||
|
||||
# Copy Gradle wrapper and build files
|
||||
COPY backend/gradlew ./
|
||||
COPY backend/gradle/ ./gradle/
|
||||
COPY backend/build.gradle ./
|
||||
COPY backend/settings.gradle ./
|
||||
|
||||
# Copy source code
|
||||
COPY backend/src/ ./src/
|
||||
|
||||
# Make gradlew executable and build
|
||||
RUN chmod +x gradlew
|
||||
RUN ./gradlew build --no-daemon -x test
|
||||
|
||||
# Stage 3: Runtime
|
||||
FROM openjdk:21-jre-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install curl for health checks
|
||||
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy built backend JAR
|
||||
COPY --from=backend-builder /app/backend/build/libs/*.jar app.jar
|
||||
|
||||
# Copy built frontend (will be served by Spring Boot)
|
||||
COPY --from=frontend-builder /app/frontend/build/ /app/static/
|
||||
|
||||
# Create non-root user
|
||||
RUN groupadd -r serena && useradd -r -g serena serena
|
||||
RUN chown -R serena:serena /app
|
||||
USER serena
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8080
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
||||
CMD curl -f http://localhost:8080/actuator/health || exit 1
|
||||
|
||||
# Run the application
|
||||
ENTRYPOINT ["java", "-jar", "app.jar"]
|
124
README.md
124
README.md
|
@ -1,2 +1,124 @@
|
|||
# team-5
|
||||
# Serena - Collaborative Radio Station Platform
|
||||
|
||||
**Serena** is a collaborative radio station platform that enables users to create and join virtual music stations for shared listening experiences. The application features a React frontend and Spring Boot backend, integrating with the Spotify API to provide real-time music playback and queue management.
|
||||
|
||||
## 🎵 Features
|
||||
|
||||
- **Create & Join Stations**: Users can create radio stations with unique join codes or join existing stations
|
||||
- **Collaborative Queuing**: Multiple users can add songs to their preferred queues
|
||||
- **Intelligent Recommendations**: Advanced algorithm considers song popularity, tempo similarity, audio features, and user preferences
|
||||
- **Real-time Playback**: Spotify integration for seamless music streaming (station owners control playback)
|
||||
- **User Authentication**: JWT-based authentication system with owner and client roles
|
||||
- **Responsive UI**: Modern React interface with animated backgrounds and intuitive controls
|
||||
|
||||
## 🏗️ Architecture
|
||||
|
||||
### Backend (Spring Boot)
|
||||
- **Language**: Java
|
||||
- **Framework**: Spring Boot
|
||||
- **Authentication**: JWT tokens
|
||||
- **Queue Algorithm**: Multi-factor recommendation system
|
||||
- **API**: RESTful endpoints for station and queue management
|
||||
|
||||
### Frontend (React)
|
||||
- **Language**: JavaScript (JSX)
|
||||
- **Framework**: React 19.1.1
|
||||
- **Routing**: React Router DOM
|
||||
- **Spotify Integration**: Web Playback SDK
|
||||
- **Styling**: CSS with animations
|
||||
|
||||
### External APIs
|
||||
- **Spotify Web API**: Music data and playback control
|
||||
- **Spotify Web Playback SDK**: Browser-based music streaming
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### Prerequisites
|
||||
- Node.js (v16+)
|
||||
- Java 11+
|
||||
- Gradle
|
||||
- Docker (optional)
|
||||
- Spotify Premium account (for playback control)
|
||||
|
||||
|
||||
### Backend Setup
|
||||
```bash
|
||||
cd backend
|
||||
./gradlew bootRun
|
||||
```
|
||||
|
||||
The backend will start on `http://localhost:8080`
|
||||
|
||||
### Frontend Setup
|
||||
```bash
|
||||
cd frontend
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
The frontend will start on `http://localhost:3000`
|
||||
|
||||
### Docker Setup (Alternative)
|
||||
```bash
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
## 📖 API Documentation
|
||||
|
||||
Detailed API documentation is available in [`backend/API_DOCUMENTATION.md`](backend/API_DOCUMENTATION.md).
|
||||
|
||||
### Key Endpoints
|
||||
- `POST /api/radio-stations` - Create a new radio station
|
||||
- `GET /api/radio-stations` - List all radio stations
|
||||
- `POST /api/clients/connect` - Join a station with join code
|
||||
- `POST /api/songs/queue` - Add song to client's preferred queue
|
||||
- `GET /api/songs/queue/recommended` - Get intelligently sorted queue
|
||||
|
||||
## 🎯 How It Works
|
||||
|
||||
### Station Creation
|
||||
1. User creates a station with name and description
|
||||
2. System generates unique station ID and 6-character join code
|
||||
3. Creator becomes the station owner with playback control
|
||||
|
||||
### Joining Stations
|
||||
1. Users join with the station's join code
|
||||
2. Receive client authentication token
|
||||
3. Can add songs to their preferred queue
|
||||
|
||||
### Queue Algorithm
|
||||
The intelligent queue system considers:
|
||||
- **Preferred Queue Position** (30%): User song preferences
|
||||
- **Popularity** (20%): Spotify popularity scores
|
||||
- **Tempo Similarity** (20%): BPM matching with current song
|
||||
- **Audio Features** (30%): Danceability, energy, valence, etc.
|
||||
|
||||
### Playback Control
|
||||
- Only station owners can control playback
|
||||
- Automatic progression through recommended queue
|
||||
- Real-time sync with Spotify Web Playback SDK
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
### Backend Configuration
|
||||
Update `backend/src/main/resources/application.properties`:
|
||||
```properties
|
||||
# Add your Spotify credentials and other settings
|
||||
```
|
||||
|
||||
### Frontend Configuration
|
||||
Update Spotify credentials in `frontend/src/constants/ApiConstants.js`
|
||||
|
||||
## 🧪 Testing
|
||||
|
||||
### Backend Tests
|
||||
```bash
|
||||
cd backend
|
||||
./gradlew test
|
||||
```
|
||||
|
||||
### Frontend Tests
|
||||
```bash
|
||||
cd frontend
|
||||
npm test
|
||||
```
|
|
@ -0,0 +1,69 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
# Backend Service
|
||||
serena-backend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: serena-backend
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
- SPRING_PROFILES_ACTIVE=docker
|
||||
- SERVER_PORT=8080
|
||||
- SPRING_WEB_CORS_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 60s
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- serena-network
|
||||
|
||||
# Frontend Development Service (alternative to built-in static files)
|
||||
serena-frontend:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile.dev
|
||||
container_name: serena-frontend
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- REACT_APP_API_URL=http://localhost:8080
|
||||
- CHOKIDAR_USEPOLLING=true
|
||||
volumes:
|
||||
- ./frontend:/app
|
||||
- /app/node_modules
|
||||
depends_on:
|
||||
- serena-backend
|
||||
networks:
|
||||
- serena-network
|
||||
profiles:
|
||||
- development
|
||||
|
||||
# Production Frontend (served by backend)
|
||||
serena-app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: serena-app
|
||||
ports:
|
||||
- "80:8080"
|
||||
environment:
|
||||
- SPRING_PROFILES_ACTIVE=production
|
||||
- SERVER_PORT=8080
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- serena-network
|
||||
profiles:
|
||||
- production
|
||||
|
||||
networks:
|
||||
serena-network:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
node_modules:
|
Loading…
Add table
Add a link
Reference in a new issue