File size: 1,236 Bytes
b0798af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
FROM node:24-bookworm-slim

# Install system build dependencies and runtime tools
RUN apt-get update && apt-get install -y --no-install-recommends \
    python3 \
    make \
    g++ \
    curl \
    ca-certificates \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Set up directory ownership for user node (UID 1000)
RUN chown -R node:node /app

# Switch to non-root user (Hugging Face Spaces default UID 1000)
USER node

# 1. Install backend dependencies
COPY --chown=node:node backend/package*.json ./backend/
RUN cd backend && npm ci

# 2. Install frontend dependencies
COPY --chown=node:node frontend/package*.json ./frontend/
RUN cd frontend && npm ci

# 3. Build backend
COPY --chown=node:node backend/ ./backend/
RUN cd backend && npm run build

# 4. Build frontend
COPY --chown=node:node frontend/ ./frontend/
RUN cd frontend && npm run build

# 5. Copy startup script
COPY --chown=node:node start.sh ./start.sh
RUN chmod +x ./start.sh

# 6. Ensure data directories exist and are writable
RUN mkdir -p /app/backend/data /app/backend/downloaded_songs

# HF Spaces communicates over port 7860
EXPOSE 7860

ENV NODE_ENV=production
ENV PORT=5000
ENV HOST=127.0.0.1
ENV API_PROXY_TARGET=http://127.0.0.1:5000

CMD ["./start.sh"]