standalone mongodb

This commit is contained in:
miaoski
2020-04-12 14:12:14 +02:00
parent c91e6255ef
commit 7de4f7370f
8 changed files with 91 additions and 15 deletions

View File

@@ -1,17 +1,32 @@
version: '3'
services:
mongo:
build: ./mongo
image: docker_open5gs_mongo
container_name: mongo
volumes:
- ./mongo:/mnt/mongo
- ./mongodb:/var/lib/mongodb
ports:
- "27017:27017"
networks:
default:
ipv4_address: 172.18.0.10
hss:
build: ./hss
image: docker_open5gs_hss
container_name: hss
volumes:
- ./hss:/mnt/hss
- ./mongodb:/var/lib/mongodb
- ./log:/open5gs/install/var/log/open5gs
environment:
- MONGO_IP=172.18.0.10
- MME_IP=172.18.0.3
- DB_URI=mongodb://172.18.0.10/open5gs
depends_on:
- mongo
ports:
- "3000:3000"
- "27017:27017"
networks:
default:
ipv4_address: 172.18.0.2
@@ -21,6 +36,7 @@ services:
container_name: sgw
volumes:
- ./sgw:/mnt/sgw
- ./log:/open5gs/install/var/log/open5gs
ports:
- "2152:2152/udp"
networks:
@@ -32,6 +48,7 @@ services:
container_name: pgw
volumes:
- ./pgw:/mnt/pgw
- ./log:/open5gs/install/var/log/open5gs
environment:
- PCRF_IP=172.18.0.6
cap_add:
@@ -53,6 +70,7 @@ services:
container_name: mme
volumes:
- ./mme:/mnt/mme
- ./log:/open5gs/install/var/log/open5gs
ports:
- "36412:36412/sctp"
environment:
@@ -67,12 +85,13 @@ services:
image: docker_open5gs_pcrf
container_name: pcrf
depends_on:
- hss
- mongo
volumes:
- ./pcrf:/mnt/pcrf
- ./log:/open5gs/install/var/log/open5gs
environment:
- PGW_IP=172.18.0.5
- HSS_IP=172.18.0.2
- MONGO_IP=172.18.0.10
networks:
default:
ipv4_address: 172.18.0.6

View File

@@ -37,9 +37,5 @@ EXPOSE 5868/sctp
# Expose port 3000 Web UI of HSS
EXPOSE 3000/tcp
# Expose port 27017 for Mongodb queries
EXPOSE 27017/udp
EXPOSE 27017/tcp
CMD /mnt/hss/hss_init.sh && \
cd install/bin && sleep 5 && ./open5gs-hssd
cd install/bin && sleep 5 && ./open5gs-hssd

View File

@@ -1,4 +1,4 @@
db_uri: mongodb://localhost/open5gs
db_uri: mongodb://MONGO_IP/open5gs
logger:
file: /open5gs/install/var/log/open5gs/hss.log

View File

@@ -26,12 +26,11 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mongod --smallfiles --dbpath /var/lib/mongodb --logpath /var/log/mongodb/mongodb.log --bind_ip 0.0.0.0 &
cd webui && npm run dev &
export IP_ADDR=$(awk 'END{print $1}' /etc/hosts)
cp /mnt/hss/hss.yaml install/etc/open5gs
sed -i 's|HSS_IP|'$IP_ADDR'|g' install/etc/open5gs/hss.yaml
sed -i 's|MME_IP|'$MME_IP'|g' install/etc/open5gs/hss.yaml
sed -i 's|MONGO_IP|'$MONGO_IP'|g' install/etc/open5gs/hss.yaml

33
mongo/Dockerfile Normal file
View File

@@ -0,0 +1,33 @@
# BSD 2-Clause License
# Copyright (c) 2019, Supreeth Herle
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FROM docker_open5gs
# Expose port 27017 for Mongodb queries
EXPOSE 27017/udp
EXPOSE 27017/tcp
CMD /mnt/mongo/mongo_init.sh

29
mongo/mongo_init.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
# BSD 2-Clause License
# Copyright (c) 2020, miaoski
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mongod --smallfiles --dbpath /var/lib/mongodb --logpath /var/log/mongodb/mongodb.log --bind_ip 0.0.0.0

View File

@@ -1,4 +1,4 @@
db_uri: mongodb://localhost/open5gs
db_uri: mongodb://MONGO_IP/open5gs
logger:
file: /open5gs/install/var/log/open5gs/pcrf.log

View File

@@ -29,8 +29,8 @@
export IP_ADDR=$(awk 'END{print $1}' /etc/hosts)
cp /mnt/pcrf/pcrf.yaml install/etc/open5gs
sed -i 's|mongodb://localhost/|mongodb://'$HSS_IP'/|g' install/etc/open5gs/pcrf.yaml
sed -i 's|MONGO_IP|'$MONGO_IP'|g' install/etc/open5gs/pcrf.yaml
sed -i 's|NAME|'$NAME'|g' install/etc/open5gs/pcrf.yaml
sed -i 's|REALM|'$REALM'|g' install/etc/open5gs/pcrf.yaml
sed -i 's|PCRF_IP|'$IP_ADDR'|g' install/etc/open5gs/pcrf.yaml
sed -i 's|PGW_IP|'$PGW_IP'|g' install/etc/open5gs/pcrf.yaml
sed -i 's|PGW_IP|'$PGW_IP'|g' install/etc/open5gs/pcrf.yaml