Spaces:
Runtime error
Runtime error
update
Browse files- Dockerfile +2 -1
- 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 |
-
|
| 6 |
-
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
#
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
#
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
| 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
|