thomwolf HF staff commited on
Commit
de97636
·
1 Parent(s): 51b4bae

add rocket chat

Browse files
Files changed (3) hide show
  1. Dockerfile +71 -0
  2. README.md +2 -3
  3. start.sh +48 -0
Dockerfile ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ubuntu:latest
2
+
3
+ # Install essential packages
4
+ RUN apt-get update && apt-get install -y \
5
+ git-all \
6
+ curl \
7
+ wget \
8
+ gnupg \
9
+ build-essential \
10
+ graphicsmagick
11
+
12
+ # Install Node.js
13
+ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
14
+ apt-get install -y nodejs
15
+
16
+ # Install MongoDB and dependencies
17
+ RUN curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \
18
+ gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg \
19
+ --dearmor \
20
+ && echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0 multiverse" | \
21
+ tee /etc/apt/sources.list.d/mongodb-org-8.0.list \
22
+ && wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb \
23
+ && dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb \
24
+ && rm libssl1.1_1.1.1f-1ubuntu2_amd64.deb \
25
+ && apt-get update \
26
+ && apt-get install -y mongodb-org mongodb-mongosh
27
+
28
+ # Create required directories and set permissions
29
+ RUN mkdir -p /data/db /opt/Rocket.Chat /var/log && \
30
+ touch /var/log/mongodb.log && \
31
+ chown -R mongodb:mongodb /data/db /var/log/mongodb.log && \
32
+ chmod 777 /data/db /var/log/mongodb.log
33
+
34
+ # Create MongoDB config file
35
+ RUN echo "storage:" > /etc/mongod.conf && \
36
+ echo " dbPath: /data/db" >> /etc/mongod.conf && \
37
+ echo "systemLog:" >> /etc/mongod.conf && \
38
+ echo " destination: file" >> /etc/mongod.conf && \
39
+ echo " path: /var/log/mongodb.log" >> /etc/mongod.conf && \
40
+ echo " logAppend: true" >> /etc/mongod.conf && \
41
+ echo "net:" >> /etc/mongod.conf && \
42
+ echo " bindIp: 127.0.0.1" >> /etc/mongod.conf && \
43
+ echo " port: 27017" >> /etc/mongod.conf && \
44
+ echo "replication:" >> /etc/mongod.conf && \
45
+ echo " replSetName: rs01" >> /etc/mongod.conf
46
+
47
+ # Create rocketchat user
48
+ RUN useradd -M rocketchat && \
49
+ usermod -L rocketchat
50
+
51
+ # Download and install Rocket.Chat
52
+ RUN curl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz && \
53
+ tar -xzf /tmp/rocket.chat.tgz -C /opt/Rocket.Chat --strip-components=1 && \
54
+ cd /opt/Rocket.Chat/programs/server && \
55
+ npm install --production && \
56
+ chown -R rocketchat:rocketchat /opt/Rocket.Chat
57
+
58
+ # Set environment variables
59
+ ENV ROOT_URL=http://localhost:7860 \
60
+ PORT=7860 \
61
+ MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01 \
62
+ MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01
63
+
64
+ # Expose necessary ports
65
+ EXPOSE 27017 7860
66
+
67
+ # Copy startup script
68
+ COPY start.sh /start.sh
69
+ RUN chmod +x /start.sh
70
+
71
+ ENTRYPOINT ["/start.sh"]
README.md CHANGED
@@ -1,11 +1,10 @@
1
  ---
2
- title: Discussion
3
  emoji: 📊
4
  colorFrom: yellow
5
- colorTo: purple
6
  sdk: docker
7
  pinned: false
8
- short_description: Discussion forum for FineWeb
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Discussion Forum
3
  emoji: 📊
4
  colorFrom: yellow
5
+ colorTo: green
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
start.sh ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -x -e
3
+
4
+ echo "Creating data directory..."
5
+ mkdir -p /data/db
6
+
7
+ echo "Starting MongoDB..."
8
+ mongod --config /etc/mongod.conf &
9
+
10
+ # Wait for MongoDB to be ready
11
+ echo "Waiting for MongoDB to start..."
12
+ max_attempts=30
13
+ attempt=1
14
+
15
+ echo $(ls -l /data/)
16
+
17
+ while ! mongosh --quiet --eval "db.version()" > /dev/null 2>&1; do
18
+ if [ $attempt -gt $max_attempts ]; then
19
+ echo "MongoDB failed to start. Showing logs:"
20
+ cat /var/log/mongodb.log
21
+ exit 1
22
+ fi
23
+ echo "Attempt $attempt of $max_attempts: MongoDB not ready yet..."
24
+ sleep 2
25
+ attempt=$((attempt + 1))
26
+ done
27
+
28
+ echo "MongoDB started successfully"
29
+
30
+ # Initialize replica set
31
+ echo "Initializing replica set..."
32
+ mongosh --eval 'rs.status()' --quiet
33
+ if ! mongosh --eval 'rs.status()' --quiet | grep -q 'ok: 1'; then
34
+ echo "Initializing replica set..."
35
+ mongosh --eval 'rs.initiate({_id: "rs01", members: [{_id: 0, host: "localhost:27017"}]})' || {
36
+ echo "Failed to initialize replica set"
37
+ }
38
+ else
39
+ echo "Replica set already initialized"
40
+ fi
41
+
42
+ echo "Waiting for replica set to initialize..."
43
+ sleep 5
44
+
45
+ # Start Rocket.Chat
46
+ echo "Starting Rocket.Chat..."
47
+ cd /opt/Rocket.Chat
48
+ exec node main.js