Spaces:
Runtime error
Runtime error
anuj
commited on
Commit
·
5552216
1
Parent(s):
f207cfd
batfa
Browse files- Dockerfile +9 -5
- start.sh +33 -4
Dockerfile
CHANGED
|
@@ -22,10 +22,14 @@ RUN curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \
|
|
| 22 |
&& dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb \
|
| 23 |
&& rm libssl1.1_1.1.1f-1ubuntu2_amd64.deb \
|
| 24 |
&& apt-get update \
|
| 25 |
-
&& apt-get install -y mongodb-org
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# Create required directories
|
| 28 |
-
RUN mkdir -p /
|
| 29 |
|
| 30 |
# Create rocketchat user
|
| 31 |
RUN useradd -M rocketchat && \
|
|
@@ -39,13 +43,13 @@ RUN curl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz
|
|
| 39 |
chown -R rocketchat:rocketchat /opt/Rocket.Chat
|
| 40 |
|
| 41 |
# Set environment variables
|
| 42 |
-
ENV ROOT_URL=http://localhost:
|
| 43 |
-
PORT=
|
| 44 |
MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01 \
|
| 45 |
MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01
|
| 46 |
|
| 47 |
# Expose necessary ports
|
| 48 |
-
EXPOSE 27017
|
| 49 |
|
| 50 |
# Copy startup script
|
| 51 |
COPY start.sh /start.sh
|
|
|
|
| 22 |
&& dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb \
|
| 23 |
&& rm libssl1.1_1.1.1f-1ubuntu2_amd64.deb \
|
| 24 |
&& apt-get update \
|
| 25 |
+
&& apt-get install -y mongodb-org mongodb-mongosh
|
| 26 |
+
|
| 27 |
+
# Create MongoDB data directory with correct permissions
|
| 28 |
+
RUN mkdir -p /data/db && \
|
| 29 |
+
chown -R rocketchat:rocketchat /data/db
|
| 30 |
|
| 31 |
# Create required directories
|
| 32 |
+
RUN mkdir -p /opt/Rocket.Chat
|
| 33 |
|
| 34 |
# Create rocketchat user
|
| 35 |
RUN useradd -M rocketchat && \
|
|
|
|
| 43 |
chown -R rocketchat:rocketchat /opt/Rocket.Chat
|
| 44 |
|
| 45 |
# Set environment variables
|
| 46 |
+
ENV ROOT_URL=http://localhost:7860 \
|
| 47 |
+
PORT=7860 \
|
| 48 |
MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01 \
|
| 49 |
MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01
|
| 50 |
|
| 51 |
# Expose necessary ports
|
| 52 |
+
EXPOSE 27017 7860
|
| 53 |
|
| 54 |
# Copy startup script
|
| 55 |
COPY start.sh /start.sh
|
start.sh
CHANGED
|
@@ -1,11 +1,40 @@
|
|
| 1 |
#!/bin/bash
|
|
|
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
# Initialize replica set
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Start Rocket.Chat
|
|
|
|
| 10 |
cd /opt/Rocket.Chat
|
| 11 |
-
node main.js
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
+
set -e
|
| 3 |
|
| 4 |
+
# Create MongoDB config file
|
| 5 |
+
cat > /tmp/mongod.conf << EOF
|
| 6 |
+
storage:
|
| 7 |
+
dbPath: /data/db
|
| 8 |
+
systemLog:
|
| 9 |
+
destination: file
|
| 10 |
+
path: /var/log/mongodb.log
|
| 11 |
+
logAppend: true
|
| 12 |
+
net:
|
| 13 |
+
bindIp: 127.0.0.1
|
| 14 |
+
port: 27017
|
| 15 |
+
replication:
|
| 16 |
+
replSetName: rs01
|
| 17 |
+
EOF
|
| 18 |
+
|
| 19 |
+
# Start MongoDB in background
|
| 20 |
+
mongod --config /tmp/mongod.conf &
|
| 21 |
+
|
| 22 |
+
# Wait for MongoDB to start
|
| 23 |
+
echo "Waiting for MongoDB to start..."
|
| 24 |
+
sleep 10
|
| 25 |
|
| 26 |
# Initialize replica set
|
| 27 |
+
echo "Initializing replica set..."
|
| 28 |
+
mongosh --eval 'rs.initiate()' || {
|
| 29 |
+
echo "Failed to initialize replica set"
|
| 30 |
+
exit 1
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
# Wait for replica set to initialize
|
| 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
|