Dockerfile 1.03 KB
Newer Older
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
FROM mongo:4.0.6

EXPOSE 27018

RUN mkdir -p /data/db2 \
    && echo "dbpath = /data/db2" > /etc/mongodb.conf \
    && chown -R mongodb:mongodb /data/db2

COPY $PWD/mongo-entrypoint/last /data/db2/scripts

COPY  $PWD/replica-set/ /vitamui/scripts/mongo/replica-set


#RUN mongod --replSet "rs0" --port=27018
#CMD mongo --port=27018 < /vitamui/scripts/mongo/replica-set/000_replicaset_dev.js && \
#    sleep 5 && \
#    mongo --port=27018 < /vitamui/scripts/mongo/replica-set/00_check_replicaset.js && \
#    cat /vitamui/scripts/mongo/data/last/*.js |  mongo --port=27018

RUN mongod --replSet "rs0" --port=27018 --fork --logpath /var/log/mongodb.log --dbpath /data/db2  \
    && CREATE_FILES=/data/db2/scripts/*.js \
    && for f in $CREATE_FILES; do mongo 127.0.0.1:27018 $f; done \
    && INSERT_FILES=/data/db2/scripts/*-insert.js \
    && for f in $INSERT_FILES; do mongo 127.0.0.1:27018 $f; done \
    && mongod --dbpath /data/db2 --shutdown \
    && chown -R mongodb /data/db2


VOLUME /data/db2

CMD ["mongod", "--config", "/etc/mongodb.conf"]