jbilcke-hf HF staff commited on
Commit
c0ab821
1 Parent(s): d860840

simplified dockerfile for aitube

Browse files
Files changed (2) hide show
  1. Dockerfile +32 -54
  2. src/app/api/v1/export/route.ts +1 -1
Dockerfile CHANGED
@@ -1,10 +1,9 @@
1
- FROM node:20-alpine AS base
 
2
 
3
- # Install dependencies only when needed
4
- FROM base AS deps
5
 
6
- # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
7
- RUN apk add --no-cache libc6-compat
8
 
9
  # for dev mode
10
  RUN apk add git git-lfs procps htop vim nano
@@ -14,69 +13,48 @@ RUN apk add alpine-sdk pkgconfig
14
  # For FFMPEG and gl concat
15
  RUN apk add curl python3 python3-dev libx11-dev libsm-dev libxrender libxext-dev mesa-dev xvfb libxi-dev glew-dev
16
 
17
- RUN apk add --no-cache ffmpeg
18
-
19
- WORKDIR /app
 
20
 
21
- # Install dependencies based on the preferred package manager
22
- COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
23
- RUN \
24
- if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
25
- elif [ -f package-lock.json ]; then npm ci --force; \
26
- elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
27
- else echo "Lockfile not found." && exit 1; \
28
- fi
29
-
30
- # Uncomment the following lines if you want to use a secret at buildtime,
31
- # for example to access your private npm packages
32
- # RUN --mount=type=secret,id=HF_EXAMPLE_SECRET,mode=0444,required=true \
33
- # $(cat /run/secrets/HF_EXAMPLE_SECRET)
34
-
35
- # Rebuild the source code only when needed
36
- FROM base AS builder
37
- WORKDIR /app
38
- COPY --from=deps /app/node_modules ./node_modules
39
- COPY . .
40
 
41
- # Next.js collects completely anonymous telemetry data about general usage.
42
- # Learn more here: https://nextjs.org/telemetry
43
- # Uncomment the following line in case you want to disable telemetry during the build.
44
- # ENV NEXT_TELEMETRY_DISABLED 1
45
-
46
- # RUN yarn build
47
 
48
- # For FFMPEG and gl concat
49
- RUN apk add curl python3 python3-dev libx11-dev libsm-dev libxrender libxext-dev mesa-dev xvfb libxi-dev glew-dev
 
50
 
51
- RUN apk add --no-cache ffmpeg
 
52
 
53
- # If you use yarn, comment out this line and use the line above
54
- RUN npm run build
55
 
56
- # Production image, copy all the files and run next
57
- FROM base AS runner
58
  WORKDIR /app
59
 
60
- ENV NODE_ENV production
61
- # Uncomment the following line in case you want to disable telemetry during runtime.
62
- # ENV NEXT_TELEMETRY_DISABLED 1
 
63
 
64
- RUN addgroup --system --gid 1001 nodejs
65
- RUN adduser --system --uid 1001 nextjs
 
 
66
 
67
- COPY --from=builder /app/public ./public
 
68
 
69
- # Automatically leverage output traces to reduce image size
70
- # https://nextjs.org/docs/advanced-features/output-file-tracing
71
- COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
72
- COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
73
- COPY --from=builder --chown=nextjs:nodejs /app/.next/cache ./.next/cache
74
- # COPY --from=builder --chown=nextjs:nodejs /app/.next/cache/fetch-cache ./.next/cache/fetch-cache
75
 
76
- USER nextjs
77
 
78
  EXPOSE 3000
79
 
80
  ENV PORT 3000
81
 
82
- CMD ["node", "server.js"]
 
1
+ # And Node 20
2
+ FROM node:20-alpine
3
 
4
+ ARG DEBIAN_FRONTEND=noninteractive
 
5
 
6
+ RUN apk update
 
7
 
8
  # for dev mode
9
  RUN apk add git git-lfs procps htop vim nano
 
13
  # For FFMPEG and gl concat
14
  RUN apk add curl python3 python3-dev libx11-dev libsm-dev libxrender libxext-dev mesa-dev xvfb libxi-dev glew-dev
15
 
16
+ # For fonts, emojis etc
17
+ RUN apk add font-terminus font-noto font-noto-cjk font-noto-extra font-noto-emoji
18
+ RUN apk add font-arabic-misc font-inconsolata font-dejavu font-awesome
19
+ RUN apk add ttf-opensans
20
 
21
+ # For Puppeteer
22
+ RUN apk add build-base gcompat udev chromium
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
+ RUN apk add --no-cache ffmpeg
 
 
 
 
 
25
 
26
+ # Set up a new user named "user" with user ID 1000
27
+ RUN adduser --disabled-password --uid 1001 user
28
+ RUN adduser --system --uid 1001 nextjs
29
 
30
+ # Switch to the "user" user
31
+ USER user
32
 
33
+ # Set home to the user's home directory
34
+ ENV PATH=.local/bin:$PATH
35
 
36
+ # Set the working directory to the user's home directory
 
37
  WORKDIR /app
38
 
39
+ # Install app dependencies
40
+ # A wildcard is used to ensure both package.json AND package-lock.json are copied
41
+ # where available (npm@5+)
42
+ COPY --chown=user package*.json /app
43
 
44
+ # make sure the .env is copied as well
45
+ COPY --chown=user .env /app
46
+
47
+ RUN ffmpeg -version
48
 
49
+ # Copy the current directory contents into the container at /app setting the owner to the user
50
+ COPY --chown=user . /app
51
 
52
+ RUN npm ci
 
 
 
 
 
53
 
54
+ RUN npm run build
55
 
56
  EXPOSE 3000
57
 
58
  ENV PORT 3000
59
 
60
+ CMD ["node", "server.js"]
src/app/api/v1/export/route.ts CHANGED
@@ -20,7 +20,7 @@ export async function POST(req: NextRequest, res: NextResponse) {
20
  // or rather, the non-turbo mode could be the one where we upscale
21
 
22
  // let's call our micro-service, which is currently open bar.
23
- console.log("[api/v1/export] sending clap to ai-tube-clap-exporter.hf.space")
24
 
25
  const result = await fetch(
26
  // `http://localhost:7860?f=${format}`,
 
20
  // or rather, the non-turbo mode could be the one where we upscale
21
 
22
  // let's call our micro-service, which is currently open bar.
23
+ console.log(`[api/v1/export] sending clap to https://jbilcke-hf-ai-tube-clap-exporter.hf.space?f=${format}`)
24
 
25
  const result = await fetch(
26
  // `http://localhost:7860?f=${format}`,