thomwolf HF staff commited on
Commit
3d24fa5
·
1 Parent(s): 8f12b69
Files changed (2) hide show
  1. Dockerfile +2 -1
  2. start.sh +37 -37
Dockerfile CHANGED
@@ -68,5 +68,6 @@ EXPOSE 27017 7860
68
  COPY start.sh /start.sh
69
  RUN chmod +x /start.sh
70
 
71
- ENTRYPOINT ["/start.sh"]
72
 
 
 
68
  COPY start.sh /start.sh
69
  RUN chmod +x /start.sh
70
 
71
+ ENTRYPOINT ["/bin/bash", "-c", "/start.sh"]
72
 
73
+ CMD ""
start.sh CHANGED
@@ -1,40 +1,40 @@
1
  #!/bin/bash
2
- set -e
3
 
4
  echo "Starting MongoDB..."
5
- # mongod --config /etc/mongod.conf &
6
-
7
- # # Wait for MongoDB to be ready
8
- # echo "Waiting for MongoDB to start..."
9
- # max_attempts=30
10
- # attempt=1
11
-
12
- # echo $(ls -l /data/)
13
-
14
- # while ! mongosh --quiet --eval "db.version()" > /dev/null 2>&1; do
15
- # if [ $attempt -gt $max_attempts ]; then
16
- # echo "MongoDB failed to start. Showing logs:"
17
- # cat /var/log/mongodb.log
18
- # exit 0
19
- # fi
20
- # echo "Attempt $attempt of $max_attempts: MongoDB not ready yet..."
21
- # sleep 2
22
- # attempt=$((attempt + 1))
23
- # done
24
-
25
- # echo "MongoDB started successfully"
26
-
27
- # # Initialize replica set
28
- # echo "Initializing replica set..."
29
- # mongosh --eval 'rs.initiate({_id: "rs01", members: [{_id: 0, host: "localhost:27017"}]})' || {
30
- # echo "Failed to initialize replica set"
31
- # exit 0
32
- # }
33
-
34
- # echo "Waiting for replica set to initialize..."
35
- # sleep 5
36
-
37
- # # Start Rocket.Chat
38
- # echo "Starting Rocket.Chat..."
39
- # cd /opt/Rocket.Chat
40
- # exec node main.js
 
1
  #!/bin/bash
2
+ set -x -e
3
 
4
  echo "Starting MongoDB..."
5
+ mongod --config /etc/mongod.conf &
6
+
7
+ # Wait for MongoDB to be ready
8
+ echo "Waiting for MongoDB to start..."
9
+ max_attempts=30
10
+ attempt=1
11
+
12
+ echo $(ls -l /data/)
13
+
14
+ while ! mongosh --quiet --eval "db.version()" > /dev/null 2>&1; do
15
+ if [ $attempt -gt $max_attempts ]; then
16
+ echo "MongoDB failed to start. Showing logs:"
17
+ cat /var/log/mongodb.log
18
+ exit 0
19
+ fi
20
+ echo "Attempt $attempt of $max_attempts: MongoDB not ready yet..."
21
+ sleep 2
22
+ attempt=$((attempt + 1))
23
+ done
24
+
25
+ echo "MongoDB started successfully"
26
+
27
+ # Initialize replica set
28
+ echo "Initializing replica set..."
29
+ mongosh --eval 'rs.initiate({_id: "rs01", members: [{_id: 0, host: "localhost:27017"}]})' || {
30
+ echo "Failed to initialize replica set"
31
+ exit 0
32
+ }
33
+
34
+ echo "Waiting for replica set to initialize..."
35
+ sleep 5
36
+
37
+ # Start Rocket.Chat
38
+ echo "Starting Rocket.Chat..."
39
+ cd /opt/Rocket.Chat
40
+ exec node main.js