atikur-rabbi commited on
Commit
6fd0ead
1 Parent(s): daa94ed
Files changed (3) hide show
  1. Dockerfile +47 -18
  2. app.js +40 -25
  3. package.json +2 -1
Dockerfile CHANGED
@@ -1,27 +1,56 @@
1
  FROM ubuntu:20.04
2
 
3
- # Install nodejs
4
- RUN apt-get update && apt-get install -y curl
5
- RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
6
- RUN apt-get install -y nodejs
7
 
8
- RUN useradd -m huggingface
 
 
 
9
 
10
- # Create app directory
11
- COPY . /home/huggingface/easy-diffusion
12
- WORKDIR /home/huggingface/easy-diffusion
13
 
14
- # Install app dependencies
15
- # A wildcard is used to ensure both package.json AND package-lock.json are copied
16
- # where available (npm@5+)
17
- # COPY package*.json ./
18
 
 
19
  RUN npm install
20
- # If you are building your code for production
21
- # RUN npm ci --only=production
22
 
23
- # Bundle app source
24
- COPY . .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
- EXPOSE 3000
27
- CMD [ "node", "app.js" ]
 
1
  FROM ubuntu:20.04
2
 
3
+ LABEL version="1.0"
 
 
 
4
 
5
+ RUN apt-get update
6
+ RUN apt-get install -y curl sudo
7
+ RUN curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
8
+ RUN apt-get install -y nodejs
9
 
10
+ # set working directory to /app
11
+ WORKDIR /app
 
12
 
13
+ # copy index.js from current directory into the container at /app
14
+ COPY . /app
 
 
15
 
16
+ # install need packages specified in package.json
17
  RUN npm install
 
 
18
 
19
+ # expose port 7860 for acessing the app
20
+ EXPOSE 7860
21
+
22
+ # This allows Heroku bind its PORT the Apps port
23
+ # since Heroku needs to use its own PORT before the App can be made accessible to the World
24
+ EXPOSE $PORT
25
+
26
+ # run app when container launches
27
+ CMD ["node", "app.js"]
28
+
29
+
30
+ # FROM ubuntu:20.04
31
+
32
+ # # Install nodejs
33
+ # RUN apt-get update && apt-get install -y curl
34
+ # RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
35
+ # RUN apt-get install -y nodejs
36
+
37
+ # RUN useradd -m huggingface
38
+
39
+ # # Create app directory
40
+ # COPY . /home/huggingface/easy-diffusion
41
+ # WORKDIR /home/huggingface/easy-diffusion
42
+
43
+ # # Install app dependencies
44
+ # # A wildcard is used to ensure both package.json AND package-lock.json are copied
45
+ # # where available (npm@5+)
46
+ # # COPY package*.json ./
47
+
48
+ # RUN npm install
49
+ # # If you are building your code for production
50
+ # # RUN npm ci --only=production
51
+
52
+ # # Bundle app source
53
+ # COPY . .
54
 
55
+ # EXPOSE 3000
56
+ # CMD [ "node", "app.js" ]
app.js CHANGED
@@ -1,34 +1,49 @@
1
- var express = require("express");
2
- var app = express();
3
- var router = express.Router();
4
 
5
- var path = __dirname + '/views/';
 
6
 
7
- // Constants
8
- const PORT = 3000;
9
- const HOST = '0.0.0.0';
10
-
11
- router.use(function (req,res,next) {
12
- console.log("/" + req.method);
13
- next();
14
  });
15
 
16
- // Hello world api
17
- router.get("/",function(req,res){
18
- res.send("Hello world!");
19
  });
20
 
21
- router.get("/home",function(req,res){
22
- res.sendFile(path + "index.html");
23
- });
24
 
25
- router.get("/sharks",function(req,res){
26
- res.sendFile(path + "sharks.html");
27
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- app.use(express.static(path));
30
- app.use("/", router);
31
 
32
- app.listen(PORT, function () {
33
- console.log(`Example app listening on port ${PORT}`)
34
- })
 
1
+ const http = require('http');
 
 
2
 
3
+ const hostname = process.env.HOST || '0.0.0.0';
4
+ const port = process.env.PORT || 7860;
5
 
6
+ const server = http.createServer((req, res) => {
7
+ res.statusCode = 200;
8
+ res.setHeader('Content-Type', 'text/plain');
9
+ res.end('Hello World');
 
 
 
10
  });
11
 
12
+ server.listen(port, hostname, () => {
13
+ console.log(`Server running at http://${hostname}:${port}/`);
 
14
  });
15
 
16
+ // var express = require("express");
17
+ // var app = express();
18
+ // var router = express.Router();
19
 
20
+ // var path = __dirname + '/views/';
21
+
22
+ // // Constants
23
+ // const PORT = 3000;
24
+ // const HOST = '0.0.0.0';
25
+
26
+ // router.use(function (req,res,next) {
27
+ // console.log("/" + req.method);
28
+ // next();
29
+ // });
30
+
31
+ // // Hello world api
32
+ // router.get("/",function(req,res){
33
+ // res.send("Hello world!");
34
+ // });
35
+
36
+ // router.get("/home",function(req,res){
37
+ // res.sendFile(path + "index.html");
38
+ // });
39
+
40
+ // router.get("/sharks",function(req,res){
41
+ // res.sendFile(path + "sharks.html");
42
+ // });
43
 
44
+ // app.use(express.static(path));
45
+ // app.use("/", router);
46
 
47
+ // app.listen(PORT, function () {
48
+ // console.log(`Example app listening on port ${PORT}`)
49
+ // })
package.json CHANGED
@@ -15,6 +15,7 @@
15
  "express"
16
  ],
17
  "dependencies": {
18
- "express": "^4.16.4"
 
19
  }
20
  }
 
15
  "express"
16
  ],
17
  "dependencies": {
18
+ "express": "^4.16.4",
19
+ "http": "0.0.0"
20
  }
21
  }