mirror of
https://github.com/wahyd4/you-music.git
synced 2026-08-09 05:06:44 +10:00
69 lines
1.6 KiB
Docker
69 lines
1.6 KiB
Docker
# Multi-stage build for frontend
|
|
FROM node:20-alpine AS frontend-builder
|
|
|
|
WORKDIR /app/frontend
|
|
|
|
# Copy frontend package files and install dependencies
|
|
COPY frontend/package.json frontend/package-lock.json ./
|
|
COPY frontend/.npmrc ./
|
|
RUN npm ci
|
|
|
|
# Copy frontend source
|
|
COPY frontend/ ./
|
|
RUN npm run build
|
|
|
|
|
|
# Final image
|
|
FROM python:3.13-slim
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
ffmpeg \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy backend requirements
|
|
COPY backend/requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy backend code
|
|
COPY backend/ ./backend/
|
|
|
|
# Make scripts executable
|
|
RUN chmod +x ./backend/run-migrations.sh ./backend/start.sh
|
|
|
|
# Copy frontend build from builder stage
|
|
COPY --from=frontend-builder /app/frontend/dist ./backend/static
|
|
|
|
# Create data directories with proper permissions
|
|
RUN mkdir -p /app/data/music \
|
|
/app/data/uploads \
|
|
/app/data/temp \
|
|
/app/data/cache/artists \
|
|
/app/data/cache/artist_images \
|
|
&& chmod -R 755 /app/data
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Environment variables
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PYTHONPATH=/app/backend
|
|
ENV DATABASE_URL=sqlite+aiosqlite:///./data/youmusic.db
|
|
ENV MUSIC_DIR=/app/data/music
|
|
ENV UPLOAD_DIR=/app/data/uploads
|
|
ENV TEMP_DIR=/app/data/temp
|
|
ENV BASE_DIR=/app
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8000/ || exit 1
|
|
|
|
# Set working directory to backend
|
|
WORKDIR /app/backend
|
|
|
|
# Run migrations and start the application
|
|
CMD ["/app/backend/start.sh"]
|