File size: 1,835 Bytes
d092f57
 
 
 
3fc322a
d092f57
 
 
 
 
 
 
 
 
 
 
 
 
3fc322a
d092f57
 
 
06105c5
 
3fc322a
d092f57
06105c5
 
d092f57
3fc322a
 
 
d092f57
16aa6cb
d092f57
 
16aa6cb
d092f57
 
 
 
 
 
 
3fc322a
d092f57
 
 
 
 
16aa6cb
 
 
d092f57
 
3fc322a
 
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
53
54
55
56
57
# Install dependencies only when needed
FROM node:21.0-alpine AS deps
WORKDIR /app

# libc6-compat helps some native deps
RUN apk add --no-cache libc6-compat

COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile

# Rebuild the source code only when needed
FROM node:21.0-alpine AS builder
WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN yarn build

# Production image, copy all the files and run Next.js
FROM node:21.0-alpine AS runner
WORKDIR /app

ENV NODE_ENV=production

# Default envs (override in Space settings)
ENV SITE_NAME="Web-SyncPlay"
# IMPORTANT: include the scheme. Replace with your actual Space URL.
ENV PUBLIC_DOMAIN="https://shivam413-Streamer.hf.space"

# Hugging Face Spaces expects your app to listen on $PORT (default 7860)
ENV PORT=7860
EXPOSE 7860

LABEL org.opencontainers.image.url="https://shivam413-Streamer.hf.space" \
      org.opencontainers.image.description="Watch videos or play music in sync with your friends" \
      org.opencontainers.image.title="Web-SyncPlay" \
      maintainer="charlie <t.me/yucant>"

RUN addgroup -g 1001 -S nodejs && \
    adduser -S nextjs -u 1001 && \
    apk add --no-cache curl python3 py3-pip &&  \
    curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp && \
    chmod a+rx /usr/local/bin/yt-dlp

# Static assets and standalone output
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

# Ensure Next.js cache directory exists and is writable
RUN mkdir -p /app/.next/cache && chown -R nextjs:nodejs /app/.next

USER nextjs

# Next.js will pick up PORT env var
CMD ["sh", "-c", "node server.js"]