Spaces:
Paused
Paused
Upload 5 files
Browse files- Dockerfile +65 -0
- next-env.d.ts +5 -0
- next.config.js +11 -0
- package.json +25 -0
- tsconfig.json +21 -0
Dockerfile
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HF Custom VNC - Dockerfile for Hugging Face Spaces
|
| 2 |
+
# Optimized for minimal size and fast startup
|
| 3 |
+
|
| 4 |
+
# Build stage
|
| 5 |
+
FROM node:18-alpine AS builder
|
| 6 |
+
|
| 7 |
+
WORKDIR /app
|
| 8 |
+
|
| 9 |
+
# Copy package files
|
| 10 |
+
COPY package*.json ./
|
| 11 |
+
|
| 12 |
+
# Install dependencies
|
| 13 |
+
RUN npm ci
|
| 14 |
+
|
| 15 |
+
# Copy source code
|
| 16 |
+
COPY . .
|
| 17 |
+
|
| 18 |
+
# Build Next.js application
|
| 19 |
+
RUN npm run build
|
| 20 |
+
|
| 21 |
+
# Production stage
|
| 22 |
+
FROM node:18-alpine AS runner
|
| 23 |
+
|
| 24 |
+
WORKDIR /app
|
| 25 |
+
|
| 26 |
+
# Create non-root user
|
| 27 |
+
RUN addgroup --system --gid 1001 nodejs
|
| 28 |
+
RUN adduser --system --uid 1001 nextjs
|
| 29 |
+
|
| 30 |
+
# Set environment variables
|
| 31 |
+
ENV NODE_ENV=production
|
| 32 |
+
ENV PORT=7860
|
| 33 |
+
|
| 34 |
+
# Copy standalone output
|
| 35 |
+
COPY --from=builder /app/.next/standalone ./
|
| 36 |
+
COPY --from=builder /app/.next/static ./.next/static
|
| 37 |
+
COPY --from=builder /app/public ./public
|
| 38 |
+
|
| 39 |
+
# Copy startup script
|
| 40 |
+
COPY --from=builder /app/scripts/start-hf.sh /app/start-hf.sh
|
| 41 |
+
RUN chmod +x /app/start-hf.sh
|
| 42 |
+
|
| 43 |
+
# Install Xvfb and tools for virtual display
|
| 44 |
+
RUN apk add --no-cache \
|
| 45 |
+
xvfb \
|
| 46 |
+
xdotool \
|
| 47 |
+
dbus \
|
| 48 |
+
ttf-freefont \
|
| 49 |
+
&& rm -rf /var/cache/apk/*
|
| 50 |
+
|
| 51 |
+
# Set ownership
|
| 52 |
+
RUN chown -R nextjs:nodejs /app
|
| 53 |
+
|
| 54 |
+
# Switch to non-root user
|
| 55 |
+
USER nextjs
|
| 56 |
+
|
| 57 |
+
# Expose port
|
| 58 |
+
EXPOSE 7860
|
| 59 |
+
|
| 60 |
+
# Health check
|
| 61 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
| 62 |
+
CMD wget --no-verbose --tries=1 --spider http://localhost:7860/ || exit 1
|
| 63 |
+
|
| 64 |
+
# Start the application
|
| 65 |
+
CMD ["/app/start-hf.sh"]
|
next-env.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/// <reference types="next" />
|
| 2 |
+
/// <reference types="next/image-types/global" />
|
| 3 |
+
|
| 4 |
+
// NOTE: This file should not be edited
|
| 5 |
+
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
next.config.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/** @type {import('next').NextConfig} */
|
| 2 |
+
const nextConfig = {
|
| 3 |
+
reactStrictMode: true,
|
| 4 |
+
output: 'standalone',
|
| 5 |
+
// Optimize for performance
|
| 6 |
+
experimental: {
|
| 7 |
+
optimizePackageImports: ['react', 'react-dom'],
|
| 8 |
+
},
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
module.exports = nextConfig;
|
package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "hf-custom-vnc",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"description": "Custom high-performance VNC implementation for Hugging Face Spaces",
|
| 5 |
+
"private": true,
|
| 6 |
+
"scripts": {
|
| 7 |
+
"dev": "next dev",
|
| 8 |
+
"build": "next build",
|
| 9 |
+
"start": "next start",
|
| 10 |
+
"start:hf": "bash scripts/start-hf.sh"
|
| 11 |
+
},
|
| 12 |
+
"dependencies": {
|
| 13 |
+
"next": "14.2.0",
|
| 14 |
+
"react": "18.3.0",
|
| 15 |
+
"react-dom": "18.3.0",
|
| 16 |
+
"puppeteer": "22.0.0",
|
| 17 |
+
"lz4js": "0.2.0"
|
| 18 |
+
},
|
| 19 |
+
"devDependencies": {
|
| 20 |
+
"@types/node": "20.11.0",
|
| 21 |
+
"@types/react": "18.2.0",
|
| 22 |
+
"@types/react-dom": "18.2.0",
|
| 23 |
+
"typescript": "5.3.0"
|
| 24 |
+
}
|
| 25 |
+
}
|
tsconfig.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"compilerOptions": {
|
| 3 |
+
"lib": ["dom", "dom.iterable", "esnext"],
|
| 4 |
+
"allowJs": true,
|
| 5 |
+
"skipLibCheck": true,
|
| 6 |
+
"strict": true,
|
| 7 |
+
"noEmit": true,
|
| 8 |
+
"esModuleInterop": true,
|
| 9 |
+
"module": "esnext",
|
| 10 |
+
"moduleResolution": "bundler",
|
| 11 |
+
"resolveJsonModule": true,
|
| 12 |
+
"isolatedModules": true,
|
| 13 |
+
"jsx": "preserve",
|
| 14 |
+
"incremental": true,
|
| 15 |
+
"paths": {
|
| 16 |
+
"@/*": ["./src/*"]
|
| 17 |
+
}
|
| 18 |
+
},
|
| 19 |
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
| 20 |
+
"exclude": ["node_modules"]
|
| 21 |
+
}
|