Spaces:
Runtime error
Runtime error
anuj
commited on
Commit
•
3547cc1
1
Parent(s):
26488bb
batman
Browse files- Dockerfile +7 -2
- start.sh +4 -5
Dockerfile
CHANGED
@@ -25,8 +25,13 @@ RUN curl -fsSL https://pgp.mongodb.com/server-5.0.asc | gpg --dearmor -o /usr/sh
|
|
25 |
&& apt-get install -y mongodb-org \
|
26 |
&& rm -rf /var/lib/apt/lists/*
|
27 |
|
28 |
-
# Create MongoDB data directory
|
29 |
-
RUN mkdir -p /data/db
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
# Install Node.js (required for Rocket.Chat)
|
32 |
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|
|
25 |
&& apt-get install -y mongodb-org \
|
26 |
&& rm -rf /var/lib/apt/lists/*
|
27 |
|
28 |
+
# Create MongoDB data directory with correct permissions
|
29 |
+
RUN mkdir -p /data/db /.mongodb && \
|
30 |
+
chown -R mongodb:mongodb /data/db /.mongodb
|
31 |
+
|
32 |
+
# Create Rocket.Chat user
|
33 |
+
RUN useradd -ms /bin/bash rocketchat
|
34 |
+
USER mongodb
|
35 |
|
36 |
# Install Node.js (required for Rocket.Chat)
|
37 |
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
start.sh
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
-
# Start MongoDB
|
4 |
-
mongod --replSet rs0 --bind_ip_all &
|
5 |
|
6 |
# Wait for MongoDB to start
|
7 |
sleep 10
|
@@ -9,6 +9,5 @@ sleep 10
|
|
9 |
# Initialize replica set
|
10 |
mongosh --eval "rs.initiate({_id: 'rs0', members: [{_id: 0, host: 'localhost:27017'}]})"
|
11 |
|
12 |
-
#
|
13 |
-
cd /app/bundle
|
14 |
-
node main.js
|
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
+
# Start MongoDB as mongodb user
|
4 |
+
mongod --replSet rs0 --bind_ip_all --dbpath /data/db &
|
5 |
|
6 |
# Wait for MongoDB to start
|
7 |
sleep 10
|
|
|
9 |
# Initialize replica set
|
10 |
mongosh --eval "rs.initiate({_id: 'rs0', members: [{_id: 0, host: 'localhost:27017'}]})"
|
11 |
|
12 |
+
# Switch to rocketchat user and start the application
|
13 |
+
su - rocketchat -c "cd /app/bundle && node main.js"
|
|