mirror of
https://github.com/MobSF/Mobile-Security-Framework-MobSF.git
synced 2026-10-12 02:06:59 +00:00
PostgreSQL support for Docker + Adding entrypoint to isolate build and run phases in Docker (#1490)
* Add Postgresql support Co-authored-by: Ajin Abraham <[email protected]> Co-authored-by: superpoussin22 <[email protected]>
This commit is contained in:
co-authored by
Ajin Abraham
superpoussin22
parent
c492729db5
commit
06f34f613d
+8
-4
@@ -86,6 +86,12 @@ RUN sed -i 's/USE_HOME = False/USE_HOME = True/g' MobSF/settings.py && \
|
||||
|
||||
# Postgres support is set to false by default
|
||||
ARG POSTGRES=False
|
||||
|
||||
ENV POSTGRES_USER=postgres
|
||||
ENV POSTGRES_PASSWORD=password
|
||||
ENV POSTGRES_DB=mobsf
|
||||
ENV POSTGRES_HOST=postgres
|
||||
|
||||
# Check if Postgres support needs to be enabled
|
||||
WORKDIR /root/Mobile-Security-Framework-MobSF/scripts
|
||||
RUN chmod +x postgres_support.sh; sync; ./postgres_support.sh $POSTGRES
|
||||
@@ -99,9 +105,7 @@ EXPOSE 8000
|
||||
# MobSF Proxy
|
||||
EXPOSE 1337
|
||||
|
||||
RUN python3 manage.py makemigrations && \
|
||||
python3 manage.py makemigrations StaticAnalyzer && \
|
||||
python3 manage.py migrate
|
||||
RUN chmod 755 /root/Mobile-Security-Framework-MobSF/scripts/entrypoint.sh
|
||||
|
||||
# Run MobSF
|
||||
CMD ["gunicorn", "-b", "0.0.0.0:8000", "MobSF.wsgi:application", "--workers=1", "--threads=10", "--timeout=1800"]
|
||||
CMD ["/root/Mobile-Security-Framework-MobSF/scripts/entrypoint.sh"]
|
||||
Executable → Regular
+4
-4
@@ -77,10 +77,10 @@ DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||
'NAME': 'mobsf',
|
||||
'USER': 'postgres',
|
||||
'PASSWORD': '',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '',
|
||||
'USER': os.environ['POSTGRES_USER'],
|
||||
'PASSWORD': os.environ['POSTGRES_PASSWORD'],
|
||||
'HOST': os.environ['POSTGRES_HOST'],
|
||||
'PORT': 5432,
|
||||
}
|
||||
}
|
||||
# End Postgres support
|
||||
|
||||
+21
-3
@@ -1,21 +1,39 @@
|
||||
version: '3'
|
||||
version: '3.8'
|
||||
services:
|
||||
postgres:
|
||||
image: "postgres:latest"
|
||||
restart: always
|
||||
volumes:
|
||||
- /Postgres_data/var/lib/postgresql:/var/lib/postgresql
|
||||
- $HOME/MobSF/postgresql_data:/var/lib/postgresql
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DB=mobsf
|
||||
ports:
|
||||
- "5432:5432"
|
||||
networks:
|
||||
- mobsf
|
||||
|
||||
mobsf:
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DB=mobsf
|
||||
- POSTGRES_HOST=postgres
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
- POSTGRES=True
|
||||
volumes:
|
||||
- /MobSF_data:/root/.MobSF
|
||||
- $HOME/MobSF/mobsf_data:/root/.MobSF
|
||||
ports:
|
||||
- "8000:8000"
|
||||
networks:
|
||||
- mobsf
|
||||
depends_on:
|
||||
- postgres
|
||||
links:
|
||||
- "postgres"
|
||||
networks:
|
||||
mobsf:
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
python3 manage.py makemigrations && \
|
||||
python3 manage.py makemigrations StaticAnalyzer && \
|
||||
python3 manage.py migrate
|
||||
|
||||
gunicorn -b 0.0.0.0:8000 "MobSF.wsgi:application" --workers=1 --threads=10 --timeout=1800
|
||||
@@ -7,7 +7,5 @@ if [ "$POSTGRES" == True ]; then
|
||||
#Enable postgres support
|
||||
sed -i '/# Sqlite3 suport/,/# End Sqlite3 support/d' ../MobSF/settings.py && \
|
||||
sed -i '/# Postgres DB - Install psycopg2/,/"""/d' ../MobSF/settings.py && \
|
||||
sed -i '/# End Postgres support/,/"""/d' ../MobSF/settings.py && \
|
||||
sed -i "s/'PASSWORD': '',/'PASSWORD': 'password',/" ../MobSF/settings.py && \
|
||||
sed -i "s/'HOST': 'localhost',/'HOST': 'postgres',/" ../MobSF/settings.py
|
||||
sed -i '/# End Postgres support/,/"""/d' ../MobSF/settings.py
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user