Spaces:
Running
Running
Commit
•
c0ab821
1
Parent(s):
d860840
simplified dockerfile for aitube
Browse files- Dockerfile +32 -54
- src/app/api/v1/export/route.ts +1 -1
Dockerfile
CHANGED
@@ -1,10 +1,9 @@
|
|
1 |
-
|
|
|
2 |
|
3 |
-
|
4 |
-
FROM base AS deps
|
5 |
|
6 |
-
|
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 |
-
|
18 |
-
|
19 |
-
|
|
|
20 |
|
21 |
-
#
|
22 |
-
|
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 |
-
|
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 |
-
#
|
49 |
-
RUN
|
|
|
50 |
|
51 |
-
|
|
|
52 |
|
53 |
-
#
|
54 |
-
|
55 |
|
56 |
-
#
|
57 |
-
FROM base AS runner
|
58 |
WORKDIR /app
|
59 |
|
60 |
-
|
61 |
-
#
|
62 |
-
#
|
|
|
63 |
|
64 |
-
|
65 |
-
|
|
|
|
|
66 |
|
67 |
-
|
|
|
68 |
|
69 |
-
|
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 |
-
|
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(
|
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}`,
|