Browse Source

handle restarts with docker instead of forever

dev_h
Ophir LOJKINE 6 years ago
parent
commit
dd9a9bf59c
4 changed files with 171 additions and 2523 deletions
  1. 4
    1
      Dockerfile
  2. 7
    2
      docker-compose.yml
  3. 159
    2518
      package-lock.json
  4. 1
    2
      package.json

+ 4
- 1
Dockerfile View File

2
 
2
 
3
 WORKDIR /opt/app
3
 WORKDIR /opt/app
4
 COPY . /opt/app
4
 COPY . /opt/app
5
+
5
 ENV PORT=80
6
 ENV PORT=80
7
+EXPOSE 80
8
+
6
 VOLUME /opt/app/server-data
9
 VOLUME /opt/app/server-data
7
 
10
 
8
 RUN touch /usr/bin/start.sh # this is the script which will run on start
11
 RUN touch /usr/bin/start.sh # this is the script which will run on start
9
 
12
 
10
 RUN echo 'npm install --production' >> /usr/bin/start.sh
13
 RUN echo 'npm install --production' >> /usr/bin/start.sh
11
-RUN echo 'npx forever --minUptime 7000 --spinSleepTime 2000 -o out.log -e err.log /opt/app/server/server.js' >> /usr/bin/start.sh
14
+RUN echo 'node /opt/app/server/server.js' >> /usr/bin/start.sh
12
 
15
 
13
 CMD ["/bin/sh","/usr/bin/start.sh"]
16
 CMD ["/bin/sh","/usr/bin/start.sh"]

+ 7
- 2
docker-compose.yml View File

1
 version: '3'
1
 version: '3'
2
 services:
2
 services:
3
   www:
3
   www:
4
-
5
     volumes:
4
     volumes:
6
       - /opt/app/:/opt/app/
5
       - /opt/app/:/opt/app/
7
     ports:
6
     ports:
8
       - '80:80'
7
       - '80:80'
9
     build:
8
     build:
10
       context: .
9
       context: .
11
-
10
+    restart: on-failure
11
+    deploy:
12
+      restart_policy:
13
+        condition: on-failure
14
+        delay: 5s
15
+        max_attempts: 5
16
+        window: 60s
12
 
17
 

+ 159
- 2518
package-lock.json
File diff suppressed because it is too large
View File


+ 1
- 2
package.json View File

6
    "version": "1.0.22",
6
    "version": "1.0.22",
7
    "license": "AGPL-3.0-or-later",
7
    "license": "AGPL-3.0-or-later",
8
    "dependencies": {
8
    "dependencies": {
9
-      "forever": "^0.15.3",
10
       "handlebars": "^4.1.1",
9
       "handlebars": "^4.1.1",
11
       "node-static": "0.7.x",
10
       "node-static": "0.7.x",
12
       "socket.io": "^2.2.0"
11
       "socket.io": "^2.2.0"
24
       "url": "http://github.com/lovasoa/whitebophir.git"
23
       "url": "http://github.com/lovasoa/whitebophir.git"
25
    },
24
    },
26
    "devDependencies": {
25
    "devDependencies": {
27
-      "openode": "^1.9.0"
26
+      "openode": "^1.9.8"
28
    }
27
    }
29
 }
28
 }

Loading…
Cancel
Save