Marcos commited on
Commit
9e80488
·
1 Parent(s): f55c577

Deploy Virtual Girlfriend backend v1

Browse files
.dockerignore CHANGED
@@ -38,4 +38,11 @@ wheels/
38
  .Spotlight-V100
39
  .Trashes
40
  ehthumbs.db
41
- Thumbs.db
 
 
 
 
 
 
 
 
38
  .Spotlight-V100
39
  .Trashes
40
  ehthumbs.db
41
+ Thumbs.db
42
+
43
+ # Node specific
44
+ backend/node_modules
45
+ backend/.env
46
+ backend/audios/*.mp3
47
+ backend/audios/*.wav
48
+ backend/audios/*.json
Dockerfile CHANGED
@@ -1,39 +1,42 @@
1
- FROM node:18
 
 
 
 
2
 
3
  # Set environment variables
4
  ENV NODE_ENV=production
 
5
 
6
- # Create a non-root user for Hugging Face Spaces (reuse existing node user)
7
- RUN usermod -l user -d /home/user -m node && groupmod -n user node
8
-
9
- # Create app directory
10
- WORKDIR /app
11
 
12
- # Create backend directory
13
- RUN mkdir -p /app/backend
14
 
15
- # Create a minimal package.json with a proper build script
16
- RUN echo '{"name":"mineru-backend","version":"1.0.0","main":"index.js","type":"module","dependencies":{"@google/generative-ai":"^0.24.1","cors":"^2.8.5","dotenv":"^16.3.1","elevenlabs-node":"^1.2.0","express":"^4.18.2","openai":"^4.26.0"},"scripts":{"dev":"node index.js","build":"echo \"Build complete. No compilation needed for this project.\""}}' > /app/backend/package.json
 
 
 
17
 
18
  # Install dependencies
19
- RUN cd /app/backend && npm install
 
 
 
20
 
21
- # Create a minimal index.js with necessary endpoints returning JSON
22
- RUN echo "import express from 'express';\nimport cors from 'cors';\nconst app = express();\napp.use(cors());\napp.use(express.json({ limit: '50mb' }));\napp.use(express.urlencoded({ extended: true, limit: '50mb' }));\nconst port = process.env.PORT || 7860;\napp.get('/', (req, res) => res.send('Backend is running'));\napp.post('/voice-chat', (req, res) => res.json({ message: 'Voice chat response', status: 'success', data: { text: req.body.text || 'Received voice chat request', audioUrl: '' } }));\napp.listen(port, () => console.log(\"Server running on port \" + port));" > /app/backend/index.js
23
 
24
- # Copy entrypoint script and set permissions
25
- COPY entrypoint.sh /app/
26
- RUN chmod +x /app/entrypoint.sh
 
27
 
28
- # Create or update entrypoint.sh to directly start the backend with node
29
- RUN echo '#!/bin/sh\ncd /app/backend\nnode index.js' > /app/entrypoint.sh
30
- RUN chmod +x /app/entrypoint.sh
31
-
32
- # Expose the port
33
  EXPOSE 7860
34
 
35
- # Switch to non-root user for running the app
36
- USER user
37
-
38
- # Set entrypoint to start the backend
39
- ENTRYPOINT ["/app/entrypoint.sh"]
 
1
+ FROM node:18-slim
2
+
3
+ # Install ffmpeg and other useful tools
4
+ RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg curl && \
5
+ apt-get clean && rm -rf /var/lib/apt/lists/*
6
 
7
  # Set environment variables
8
  ENV NODE_ENV=production
9
+ ENV PORT=7860
10
 
11
+ # Create a non-root user and switch to it
12
+ # Using the existing 'node' user that comes with the official node images
13
+ USER node
 
 
14
 
15
+ # Create app directory and set it as working directory
16
+ WORKDIR /home/node/app
17
 
18
+ # Copy package.json and package-lock.json (or yarn.lock) first
19
+ # This allows Docker to cache the npm install step if these files don't change
20
+ COPY --chown=node:node backend/package.json backend/package-lock.json* ./
21
+ # If you use yarn, uncomment the next line and comment out the npm ci line
22
+ # COPY --chown=node:node backend/yarn.lock ./
23
 
24
  # Install dependencies
25
+ # Using npm ci for cleaner installs if package-lock.json is present
26
+ RUN npm ci --only=production
27
+ # If you use yarn, uncomment the next line and comment out the npm ci line
28
+ # RUN yarn install --production --frozen-lockfile
29
 
30
+ # Copy the rest of the application files from the backend directory
31
+ COPY --chown=node:node backend/ ./
32
 
33
+ # Create audios and public directories if they might not be copied (e.g., if empty or in .dockerignore of the source)
34
+ # The application tries to create them, but it's good practice if they are expected.
35
+ # However, COPY backend/ . should bring them if they exist in the source 'backend' directory.
36
+ # RUN mkdir -p audios public
37
 
38
+ # Expose the port the app runs on
 
 
 
 
39
  EXPOSE 7860
40
 
41
+ # Command to run the application
42
+ CMD [ "node", "index.js" ]
 
 
 
README.md CHANGED
@@ -1,15 +1,24 @@
1
  ---
2
- title: MinerU PDF Converter
3
- emoji: 📄
4
- colorFrom: blue
5
- colorTo: green
6
  sdk: docker
7
  app_port: 7860
8
  ---
9
 
10
- # MinerU PDF Converter
11
 
12
- This Space provides a service for converting PDF files to Markdown and JSON formats using the MinerU PDF extraction tool.
 
 
 
 
 
 
 
 
 
13
 
14
  ## Features
15
 
 
1
  ---
2
+ title: Virtual Girlfriend Backend
3
+ emoji: 🤖
4
+ colorFrom: pink
5
+ colorTo: purple
6
  sdk: docker
7
  app_port: 7860
8
  ---
9
 
10
+ # Virtual Girlfriend Backend
11
 
12
+ This Space hosts the backend for the R3F Virtual Girlfriend application.
13
+ It provides APIs for chat, voice interaction, and text-to-speech with lip sync.
14
+
15
+ ## Endpoints
16
+
17
+ - `/chat`: Handles text-based chat interactions.
18
+ - `/voice-chat`: Handles voice-based chat interactions.
19
+ - `/voices`: Lists available voices from ElevenLabs.
20
+
21
+ (You can add more details about your API, how to use it, etc.)
22
 
23
  ## Features
24
 
backend DELETED
@@ -1 +0,0 @@
1
- Subproject commit 99a28296d9003b3a6a526e18cc56807e5f4aa54d
 
 
backend-new/index.js DELETED
@@ -1 +0,0 @@
1
- import express from 'express';
 
 
backend-new/package.json DELETED
File without changes
backend-new/public/index.html DELETED
File without changes
entrypoint.sh DELETED
@@ -1,11 +0,0 @@
1
- #!/bin/sh
2
- set -e
3
-
4
- # Hugging Face Spaces will route traffic to the first process that binds to the PORT env variable (default 7860)
5
- # Ensure we are in the backend directory and start the server.
6
- cd /app/backend
7
-
8
- # Echo for debugging
9
- echo "Starting backend on PORT=${PORT:-7860}"
10
-
11
- exec node index.js
 
 
 
 
 
 
 
 
 
 
 
 
frontend DELETED
@@ -1 +0,0 @@
1
- Subproject commit 37024ae3bc86f9fc7b98ba03c8fae57c0af3fa0d