Programmer-RD-AI
commited on
Commit
·
2f9cccb
1
Parent(s):
965e3b5
feat: add complete Next.js frontend for HF Spaces
Browse files- .dockerignore +27 -0
- Dockerfile +66 -0
- next.config.ts +2 -1
.dockerignore
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
node_modules
|
2 |
+
npm-debug.log*
|
3 |
+
yarn-debug.log*
|
4 |
+
yarn-error.log*
|
5 |
+
.pnpm-debug.log*
|
6 |
+
|
7 |
+
.next
|
8 |
+
.nuxt
|
9 |
+
dist
|
10 |
+
build
|
11 |
+
|
12 |
+
.env.local
|
13 |
+
.env.development.local
|
14 |
+
.env.test.local
|
15 |
+
.env.production.local
|
16 |
+
|
17 |
+
.git
|
18 |
+
.gitignore
|
19 |
+
README.md
|
20 |
+
Dockerfile
|
21 |
+
.dockerignore
|
22 |
+
|
23 |
+
coverage
|
24 |
+
.nyc_output
|
25 |
+
|
26 |
+
.DS_Store
|
27 |
+
Thumbs.db
|
Dockerfile
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use Node.js 18 Alpine for smaller image size
|
2 |
+
FROM node:18-alpine AS base
|
3 |
+
|
4 |
+
# Install dependencies only when needed
|
5 |
+
FROM base AS deps
|
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 |
+
WORKDIR /app
|
9 |
+
|
10 |
+
# Install dependencies based on the preferred package manager
|
11 |
+
COPY package*.json pnpm-lock.yaml* ./
|
12 |
+
RUN \
|
13 |
+
if [ -f pnpm-lock.yaml ]; then \
|
14 |
+
corepack enable pnpm && pnpm i --frozen-lockfile; \
|
15 |
+
elif [ -f package-lock.json ]; then \
|
16 |
+
npm ci; \
|
17 |
+
else \
|
18 |
+
echo "Lockfile not found." && exit 1; \
|
19 |
+
fi
|
20 |
+
|
21 |
+
# Rebuild the source code only when needed
|
22 |
+
FROM base AS builder
|
23 |
+
WORKDIR /app
|
24 |
+
COPY --from=deps /app/node_modules ./node_modules
|
25 |
+
COPY . .
|
26 |
+
|
27 |
+
# Build the Next.js application
|
28 |
+
RUN \
|
29 |
+
if [ -f pnpm-lock.yaml ]; then \
|
30 |
+
corepack enable pnpm && pnpm run build; \
|
31 |
+
else \
|
32 |
+
npm run build; \
|
33 |
+
fi
|
34 |
+
|
35 |
+
# Production image, copy all the files and run next
|
36 |
+
FROM base AS runner
|
37 |
+
WORKDIR /app
|
38 |
+
|
39 |
+
ENV NODE_ENV production
|
40 |
+
# Uncomment the following line in case you want to disable telemetry during runtime.
|
41 |
+
# ENV NEXT_TELEMETRY_DISABLED 1
|
42 |
+
|
43 |
+
RUN addgroup --system --gid 1001 nodejs
|
44 |
+
RUN adduser --system --uid 1001 nextjs
|
45 |
+
|
46 |
+
COPY --from=builder /app/public ./public
|
47 |
+
|
48 |
+
# Set the correct permission for prerender cache
|
49 |
+
RUN mkdir .next
|
50 |
+
RUN chown nextjs:nodejs .next
|
51 |
+
|
52 |
+
# Automatically leverage output traces to reduce image size
|
53 |
+
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
54 |
+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
55 |
+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
56 |
+
|
57 |
+
USER nextjs
|
58 |
+
|
59 |
+
# Expose port 7860 (Hugging Face Spaces default)
|
60 |
+
EXPOSE 7860
|
61 |
+
|
62 |
+
ENV PORT 7860
|
63 |
+
ENV HOSTNAME "0.0.0.0"
|
64 |
+
|
65 |
+
# Run the application
|
66 |
+
CMD ["node", "server.js"]
|
next.config.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
import type { NextConfig } from 'next'
|
2 |
|
3 |
const nextConfig: NextConfig = {
|
4 |
-
devIndicators: false
|
|
|
5 |
}
|
6 |
|
7 |
export default nextConfig
|
|
|
1 |
import type { NextConfig } from 'next'
|
2 |
|
3 |
const nextConfig: NextConfig = {
|
4 |
+
devIndicators: false,
|
5 |
+
output: 'standalone'
|
6 |
}
|
7 |
|
8 |
export default nextConfig
|