diff --git a/Dockerfile.debian.base b/Dockerfile.debian.base new file mode 100644 index 0000000000000000000000000000000000000000..ddc2bef9f9cfc9211745b007c1241a415d62fbdc --- /dev/null +++ b/Dockerfile.debian.base @@ -0,0 +1,24 @@ +FROM debian:buster + +ENV LC_ALL en_US.utf8 + +RUN apt-get update +RUN echo "Set up container's locales" +RUN echo -e 'LANG="en_US.UTF-8"\nLANGUAGE="en_US"\n' > /etc/default/locale +RUN echo "en_US.utf8 UTF-8" >> /etc/locale.gen +RUN apt-get -qqy install locales + +RUN mkdir -p /var/log/fod /srv +#COPY . /srv/flowspy +COPY install-debian.sh requirements.txt /srv/flowspy/ + +RUN apt-get -qqy install patch + +#RUN (cd /srv/flowspy; ./install-debian.sh;) +RUN (cd /srv/flowspy; ./install-debian.sh --basesw;) + +#EXPOSE 8000 + +#CMD [ "/srv/flowspy/runfod.sh" ] +CMD [ "sleep" "10000000" ] + diff --git a/Dockerfile.debian.step2 b/Dockerfile.debian.step2 new file mode 100644 index 0000000000000000000000000000000000000000..fd038da1e71aefa1bbda7ab85bdba58596cb5bba --- /dev/null +++ b/Dockerfile.debian.step2 @@ -0,0 +1,26 @@ +#FROM debian:buster +FROM fodpy3-debian_base + +ENV LC_ALL en_US.utf8 + +RUN apt-get update +RUN echo "Set up container's locales" +RUN echo -e 'LANG="en_US.UTF-8"\nLANGUAGE="en_US"\n' > /etc/default/locale +RUN echo "en_US.utf8 UTF-8" >> /etc/locale.gen +RUN apt-get -qqy install locales + +RUN mkdir -p /var/log/fod /srv +COPY . /srv/flowspy + +RUN apt-get -qqy install patch +RUN (cd /srv/flowspy/flowspy && cp -f settings.py.dist settings.py && patch settings.py < settings.py.patch && touch settings_local.py;) + +#RUN (cd /srv/flowspy; bash ./install-debian.sh;) +RUN (cd /srv/flowspy; ./install-debian.sh --fodproper;) + +EXPOSE 8000 + +WORKDIR /srv/flowspy + +CMD [ "/srv/flowspy/runfod.sh" ] + diff --git a/install-debian.sh b/install-debian.sh index 99cff5636d1019391540e1518a760842f95928ec..831c62399e8724eed54977407aead46dc2fda0b3 100755 --- a/install-debian.sh +++ b/install-debian.sh @@ -1,27 +1,71 @@ -set -e - -echo "Install dependencies" -apt-get -qqy update -apt-get -qqy install python3-virtualenv python3-venv python3-setuptools \ - python3-dev vim git build-essential libevent-dev libxml2-dev libxslt1-dev \ - mariadb-server libmariadb-dev patch redis-server - -echo "Setup python environment for FoD" -mkdir -p /var/log/fod /srv -pyvenv /srv/venv -( +#!/bin/bash +# +# This script installs all dependencies for Firewall-on-Demand running in Python3 +# with Celery, Redis, and sqlite. +# + +install_basesw=1 +install_fodproper=1 +if [ $# -ge 1 -a "$1" = "--both" ]; then + shift 1 + install_basesw=1 + install_fodproper=1 +elif [ $# -ge 1 -a "$1" = "--basesw" ]; then + shift 1 + install_basesw=1 + install_fodproper=0 +elif [ $# -ge 1 -a "$1" = "--fodproper" ]; then + shift 1 + install_basesw=0 + install_fodproper=1 +fi + +## + +if [ "$install_basesw" = 1 ]; then + + set -e + + echo "Install dependencies" + apt-get -qqy update + apt-get -qqy install python3-virtualenv python3-venv python3-setuptools \ + python3-dev vim git build-essential libevent-dev libxml2-dev libxslt1-dev \ + mariadb-server libmariadb-dev patch redis-server \ + rustc libssl-dev \ + procps + + set +e + +fi + +if [ "$install_fodproper" = 0 ]; then + + echo "Setup partial python environment for FoD" + + mkdir -p /srv + pyvenv /srv/venv + source /srv/venv/bin/activate + pip install wheel + pip install -r requirements.txt + +else + + echo "Setup python environment for FoD" + mkdir -p /var/log/fod /srv + pyvenv /srv/venv + ( set +e source /srv/venv/bin/activate mkdir -p /srv/flowspy/ # Select source dir and copy FoD into /srv/flowspy/ - if [ "`basename "$0"`" = install-debian.sh ]; then + if [ "`basename "$0"`" = install-centos.sh ]; then # this script is in the source directory cp -f -r "`dirname $0`"/* /srv/flowspy/ elif [ -e /vagrant ]; then # vagrant's copy in /vagrant/ cp -f -r /vagrant/* /srv/flowspy/ - elif [ -e ./install-debian.sh ]; then + elif [ -e ./install-centos.sh ]; then # current directory is with the sourcecode cp -f -r ./* /srv/flowspy/ else @@ -37,12 +81,19 @@ pyvenv /srv/venv cp -f settings.py.dist settings.py patch settings.py < settings.py.patch ) - pip install wheel pip install -r requirements.txt touch flowspy/settings_local.py - ./manage.py collectstatic + #./manage.py syncdb --noinput + mkdir -p /srv/flowspy/static/ + ./manage.py collectstatic --noinput ./manage.py migrate ./manage.py loaddata initial_data -) + ) + + set +e + +fi + +