Mohamed Abu Basith commited on
Commit
7994378
·
1 Parent(s): 2d7aaa3

CHG: checking

Browse files
Files changed (2) hide show
  1. Dockerfile +19 -0
  2. server.js +18 -0
Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:21
2
+
3
+ # Set the working directory
4
+ WORKDIR /app
5
+
6
+ # Copy package files to the working directory
7
+ COPY package*.json ./
8
+
9
+ # Install production dependencies
10
+ RUN npm ci --only=production
11
+
12
+ # Copy the rest of your app's source code
13
+ COPY . .
14
+
15
+ # Expose the port your app will run on
16
+ EXPOSE 7860
17
+
18
+ # Start the Node.js application
19
+ CMD ["node", "server.js"]
server.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const http = require('http');
2
+
3
+ const PORT = process.env.PORT || 7860;
4
+
5
+ const requestHandler = (req, res) => {
6
+ console.log(`${req.method} ${req.url}`);
7
+ res.writeHead(200, { 'Content-Type': 'text/plain' });
8
+ res.end('Hello from Node.js server!');
9
+ };
10
+
11
+ const server = http.createServer(requestHandler);
12
+
13
+ server.listen(PORT, (err) => {
14
+ if (err) {
15
+ return console.error('Error starting server:', err);
16
+ }
17
+ console.log(`Server is running on port ${PORT}`);
18
+ });