Skip to content

Commit 019251d

Browse files
committed
Dockerize a mongo instance with a replSet of 1
1 parent 17c68d7 commit 019251d

3 files changed

Lines changed: 10 additions & 17 deletions

File tree

Dockerfile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
FROM python:3.8-slim-buster AS build
1+
FROM mongo:4
22

3-
COPY requirements-dev.txt .
4-
RUN pip install --upgrade pip
5-
RUN pip install -r requirements-dev.txt
6-
RUN pip install "pymongo>=3.4,<4.0"
7-
8-
WORKDIR /app
9-
COPY . ./
3+
COPY ./entrypoint.sh entrypoint.sh
4+
RUN chmod u+x entrypoint.sh
5+
ENTRYPOINT ./entrypoint.sh

docker-compose.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,5 @@ services:
44
build:
55
context: .
66
image: mongoengine:latest
7-
network_mode: host
8-
depends_on:
9-
- mongo
10-
working_dir: /app
11-
volumes:
12-
- .:/app
13-
mongo:
14-
image: mongo:4
15-
restart: always
167
ports:
178
- 27017:27017

entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/bash
2+
3+
mongod --replSet mongoengine --fork --logpath=/var/log/mongodb.log
4+
mongo db --eval "rs.initiate()"
5+
mongod --shutdown
6+
mongod --replSet mongoengine --bind_ip 0.0.0.0

0 commit comments

Comments
 (0)