Abmacode12 commited on
Commit
7712ddd
Β·
verified Β·
1 Parent(s): 78f4b2b

FROM node:20-alpine

Browse files

WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm install --omit=dev
COPY server.js ./
EXPOSE 3000
CMD ["node", "server.js"]

Files changed (4) hide show
  1. Dockerfile +26 -0
  2. docker-compose.yml +31 -0
  3. index.html +17 -0
  4. rosalinda-server/server.js +17 -3
Dockerfile ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ```dockerfile
2
+ FROM node:20-alpine
3
+
4
+ WORKDIR /app
5
+
6
+ # Install dependencies first for better caching
7
+ COPY package.json package-lock.json* ./
8
+ RUN npm install --omit=dev
9
+
10
+ # Copy server files
11
+ COPY rosalinda-server/server.js ./
12
+ COPY rosalinda-server/server-ollama.js ./
13
+
14
+ # Create necessary directories
15
+ RUN mkdir -p /app/logs
16
+
17
+ # Expose port
18
+ EXPOSE 3000
19
+
20
+ # Health check
21
+ HEALTHCHECK --interval=30s --timeout=3s \
22
+ CMD wget -qO- http://localhost:3000/health || exit 1
23
+
24
+ # Start command with error handling
25
+ CMD ["node", "server.js"]
26
+ ```
docker-compose.yml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ```yaml
2
+ version: '3.8'
3
+
4
+ services:
5
+ rosalinda:
6
+ build: .
7
+ ports:
8
+ - "3000:3000"
9
+ environment:
10
+ - ROSALINDA_TOKEN=${ROSALINDA_TOKEN}
11
+ - NODE_ENV=production
12
+ volumes:
13
+ - ./logs:/app/logs
14
+ restart: unless-stopped
15
+ healthcheck:
16
+ test: ["CMD", "wget", "-qO-", "http://localhost:3000/health"]
17
+ interval: 30s
18
+ timeout: 3s
19
+ retries: 3
20
+
21
+ ollama:
22
+ image: ollama/ollama
23
+ ports:
24
+ - "11434:11434"
25
+ volumes:
26
+ - ollama_data:/root/.ollama
27
+ restart: unless-stopped
28
+
29
+ volumes:
30
+ ollama_data:
31
+ ```
index.html CHANGED
@@ -277,3 +277,20 @@ input.addEventListener("keydown", (e) => {
277
  handleSend();
278
  }
279
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  handleSend();
278
  }
279
  });
280
+ ollama pull llama3.1
281
+ {
282
+ "name": "rosalinda-server",
283
+ "type": "module",
284
+ "dependencies": {
285
+ "cors": "^2.8.5",
286
+ "express": "^4.19.2",
287
+ "helmet": "^7.1.0",
288
+ "express-rate-limit": "^7.4.0",
289
+ "node-fetch": "^3.3.2"
290
+ }
291
+ }
292
+ cd C:\rosalinda-server
293
+ npm install
294
+ setx ROSALINDA_INTERNAL_TOKEN "mon_super_secret"
295
+ # ferme / rouvre PowerShell
296
+ node server.js
rosalinda-server/server.js CHANGED
@@ -85,10 +85,24 @@ app.post("/rosalinda/chat", async (req, res) => {
85
  });
86
  }
87
  });
 
 
 
 
88
 
89
  const PORT = process.env.PORT || 3000;
90
  app.listen(PORT, () => {
91
- console.log(`βœ… Rosalinda server running on port ${PORT}`);
92
- console.log(`πŸ”‘ Token: ${INTERNAL_TOKEN.substring(0, 4)}...`);
93
- console.log(`🌐 Health check: http://localhost:${PORT}/health`);
 
 
 
 
 
 
 
 
 
 
94
  });
 
85
  });
86
  }
87
  });
88
+ // Logging setup
89
+ const fs = require('fs');
90
+ const logStream = fs.createWriteStream('/app/logs/server.log', { flags: 'a' });
91
+ process.stdout.write = process.stderr.write = logStream.write.bind(logStream);
92
 
93
  const PORT = process.env.PORT || 3000;
94
  app.listen(PORT, () => {
95
+ const startMessage = `
96
+ βœ… Rosalinda server running on port ${PORT}
97
+ πŸ”‘ Token: ${INTERNAL_TOKEN.substring(0, 4)}...
98
+ 🌐 Health check: http://localhost:${PORT}/health
99
+ πŸ‹ Connected to Ollama: ${process.env.OLLAMA_URL || 'Not configured'}
100
+ `;
101
+
102
+ console.log(startMessage);
103
+
104
+ // Write to Docker logs
105
+ if (process.env.NODE_ENV === 'production') {
106
+ fs.writeFileSync('/app/logs/startup.log', startMessage);
107
+ }
108
  });