Added Docker support

This commit is contained in:
Netkas 2021-01-08 19:43:27 -05:00
parent 6a41e75852
commit 22cc9ad1d5
10 changed files with 133 additions and 1 deletions

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../../../../:\Users\Netkas\Documents\gits\CoffeeHousePy\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

12
.idea/CoffeeHousePy.iml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/CoffeeHousePy.iml" filepath="$PROJECT_DIR$/.idea/CoffeeHousePy.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

36
Docker/bootstrap Normal file
View File

@ -0,0 +1,36 @@
#!/bin/sh
echo "### Initializing CoffeeHouse-Utils ###"
chmod a+x /usr/local/bin/update_server
if [ ! -f /firstrun.pass ]; then
echo "(!) First run! Installing resources..."
update_server
echo "(+) Setting boot flag..."
touch /firstrun.pass
echo "[...] Restarting server in detached mode..."
else
cd /CoffeeHousePy
echo "### Starting CoffeeHouse-LangDetect ###"
make start_langdetect &
echo "### Starting CoffeeHouse-SpamDetect ###"
make start_spamdetect &
while sleep 60; do
# If grep find anything, they exit with 0 status
# If they are not 0, then something is wrong
ps aux | grep coffeehouse_languagedetection | grep -q -v grep
LANGDETECT_STATUS=$?
if [ $LANGDETECT_STATUS -ne 0 ]; then
echo "ERROR: coffeehouse_languagedetection has been terminated, terminating container."
exit 1
fi
ps aux | grep coffeehouse_spamdetection | grep -q -v grep
SPAMDETECT_STATUS=$?
if [ $SPAMDETECT_STATUS -ne 0 ]; then
echo "ERROR: coffeehouse_spamdetection has been terminated, terminating container."
exit 1
fi
done
fi

25
Docker/update_server Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
# Written by Netkas 3/01/2021
echo "Intellivoid Provisioning"
echo "Running on x86_64 (docker) [PRODUCTION]"
echo " "
echo " ## Authentication Required "
read -p 'Enter your 25-50 character PAT: ' GIT_API_KEY
echo " #### Cloning CoffeeHousePy"
git clone https://${GIT_API_KEY}@github.com/Intellivoid/CoffeeHousePy.git
cd /CoffeeHousePy
git checkout production
echo " #### Preparing System for Python"
make system_prep_python
echo " #### Preparing System for pip"
make system_prep_pip
echo " #### Preparing System for GCC"
make system_prep_gcc
echo " #### Building and Installing CoffeeHousePy"
make install

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM ubuntu:18.04
EXPOSE 5606 5601 5603
MAINTAINER Diederik Noordhuis (diederikn@intellivoid.net)
ARG DEBIAN_FRONTEND=noninteractive
COPY Docker/bootstrap /usr/local/bin/bootstrap
COPY Docker/update_server /usr/local/bin/update_server
RUN \
apt-get update && \
ln -fs /usr/share/zoneinfo/UTC /etc/localtime && \
apt-get update && \
apt-get install git make sudo nano vim wget curl unzip -y && \
apt-get clean
CMD ["/bin/bash", "/usr/local/bin/bootstrap"]

View File

@ -163,4 +163,15 @@ start_spamdetect:
python3 -m coffeehouse_spamdetection --start-server
start_translation:
python3 -m coffeehouse_translation --start-server
python3 -m coffeehouse_translation --start-server
# ======================================================================================================================
docker_build:
docker build -t="coffeehouse_utils" -f Dockerfile .
docker_run:
docker run -it --name coffeehouse_utils -h coffeehouse_utils --restart always -p 5601:5601 -p 5606:5606 -p 5603:5603 coffeehouse_utils
docker_rm:
docker rm -f coffeehouse_utils