GreenRunchly commited on
Commit
695da0d
·
verified ·
1 Parent(s): 819ce72

Init Simple API

Browse files
Files changed (3) hide show
  1. Dockerfile +18 -0
  2. index.js +11 -0
  3. package.json +11 -0
Dockerfile ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use official Node.js base image
2
+ FROM node:18-alpine
3
+
4
+ # Set working directory inside container
5
+ WORKDIR /usr/src/app
6
+
7
+ # Copy package files and install dependencies
8
+ COPY package*.json ./
9
+ RUN npm install
10
+
11
+ # Copy app files
12
+ COPY . .
13
+
14
+ # Expose the port the app runs on
15
+ EXPOSE 3000
16
+
17
+ # Start the application
18
+ CMD ["npm", "start"]
index.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const app = express();
3
+ const PORT = process.env.PORT || 3000;
4
+
5
+ app.get('/', (req, res) => {
6
+ res.json({ message: 'Hello from Node.js API!' });
7
+ });
8
+
9
+ app.listen(PORT, () => {
10
+ console.log(`Server is running on port ${PORT}`);
11
+ });
package.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "simple-api",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "start": "node index.js"
7
+ },
8
+ "dependencies": {
9
+ "express": "^4.18.2"
10
+ }
11
+ }