Spaces:
Running
Running
File size: 2,216 Bytes
ff2e80d 0a0e3a7 9862ed7 0a0e3a7 098efa4 b7d0d3a 22d7251 b7d0d3a 22d7251 b7d0d3a 22d7251 ff2e80d 22d7251 ff2e80d 0a0e3a7 9862ed7 b7d0d3a 93faa9e b7d0d3a ff2e80d | 1 2 3 4 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | FROM python:3.12-bookworm
ENV DEBIAN_FRONTEND=noninteractive
RUN useradd -m -u 1000 user
WORKDIR /app
COPY ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
RUN apt-get update && apt-get install -y \
curl \
ca-certificates \
tar \
gzip \
procps \
libcurl4 \
libgssapi-krb5-2 \
libwrap0 \
libsasl2-2 \
libsasl2-modules \
libsasl2-modules-gssapi-mit \
openssl \
liblzma5 \
libldap-2.5-0 \
libldap-common \
&& rm -rf /var/lib/apt/lists/*
ARG MONGO_VERSION=7.0.24
ARG MONGO_TARBALL_URL=https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-${MONGO_VERSION}.tgz
RUN curl -fsSL "${MONGO_TARBALL_URL}" -o /tmp/mongodb.tgz \
&& tar -xzf /tmp/mongodb.tgz -C /opt \
&& ln -s /opt/mongodb-linux-x86_64-ubuntu2204-${MONGO_VERSION} /opt/mongodb \
&& ln -s /opt/mongodb/bin/mongod /usr/local/bin/mongod \
&& ln -s /opt/mongodb/bin/mongos /usr/local/bin/mongos \
&& rm /tmp/mongodb.tgz
COPY --chown=user . /app
USER user
ENTRYPOINT ["/bin/bash", "-lc", "\
mkdir -p /tmp/mongo-data /tmp/mongo-logs /tmp/mongo-run && \
rm -f /tmp/mongo-run/mongod.pid && \
mongod --bind_ip 127.0.0.1 \
--dbpath /tmp/mongo-data \
--logpath /tmp/mongo-logs/mongod.log \
--pidfilepath /tmp/mongo-run/mongod.pid \
--logappend \
--fork && \
sleep 3 && \
python -c \"from pymongo import MongoClient; c = MongoClient('mongodb://127.0.0.1:27017/', serverSelectionTimeoutMS=5000); print(c.admin.command('ping'))\" && \
python -c \"from pymongo import MongoClient; c = MongoClient('mongodb://127.0.0.1:27017/', serverSelectionTimeoutMS=5000); db = c['huggingFaceData']; db.create_collection('rooms') if 'rooms' not in db.list_collection_names() else None; db.create_collection('counters') if 'counters' not in db.list_collection_names() else None; db.counters.update_one({'_id':'room_id'}, {'\\$setOnInsert': {'seq': 0}}, upsert=True); db.rooms.create_index('user_id'); print('Mongo init complete')\" && \
exec \"$@\"", "--"]
CMD ["gunicorn", "-k", "geventwebsocket.gunicorn.workers.GeventWebSocketWorker", "-w", "1", "--bind", "0.0.0.0:7860", "chat_application.main:app"] |