Commit e0b18b94 authored by Artem Baranovskyi's avatar Artem Baranovskyi
Browse files

Moodle and Python services are separated to isolated services.

parent 9685721c
...@@ -14,4 +14,4 @@ MOODLE_WWWROOT=https://www.moodle.loc ...@@ -14,4 +14,4 @@ MOODLE_WWWROOT=https://www.moodle.loc
MOODLE_FULLNAME="Moodle LMS Site" MOODLE_FULLNAME="Moodle LMS Site"
MOODLE_SHORTNAME="Moodle" MOODLE_SHORTNAME="Moodle"
FLASK_APP=/var/www/html/moodle/api.py FLASK_APP=/app/api.py
\ No newline at end of file \ No newline at end of file
...@@ -17,7 +17,7 @@ ENV MOODLE_BASE_DIR_DATA ${MOODLE_BASE_DIR_DATA} ...@@ -17,7 +17,7 @@ ENV MOODLE_BASE_DIR_DATA ${MOODLE_BASE_DIR_DATA}
# Installing necessary packages # Installing necessary packages
RUN apt-get update && apt-get upgrade -y && \ RUN apt-get update && apt-get upgrade -y && \
apt-get install -y apache2 php libapache2-mod-php php-mysqli php-mysql php-xml php-pdo php-pdo-mysql mariadb-client mariadb-server wget unzip p7zip-full python3 python3-pip iputils-ping php-mbstring graphviz aspell ghostscript clamav php8.2-pspell php8.2-curl php8.2-gd php8.2-intl php8.2-mysql php8.2-xml php8.2-xmlrpc php8.2-ldap php8.2-zip php8.2-soap php8.2-mbstring openssl git nano supervisor php-xdebug && \ apt-get install -y apache2 php libapache2-mod-php php-mysqli php-mysql php-xml php-pdo php-pdo-mysql mariadb-client mariadb-server wget unzip p7zip-full iputils-ping php-mbstring graphviz aspell ghostscript clamav php8.2-pspell php8.2-curl php8.2-gd php8.2-intl php8.2-mysql php8.2-xml php8.2-xmlrpc php8.2-ldap php8.2-zip php8.2-soap php8.2-mbstring openssl git nano supervisor php-xdebug && \
apt-get clean && rm -rf /var/lib/apt/lists/* apt-get clean && rm -rf /var/lib/apt/lists/*
# Setting necessary php params # Setting necessary php params
...@@ -33,51 +33,19 @@ RUN echo "max_input_vars = 5000" >> /etc/php/8.2/cli/php.ini ...@@ -33,51 +33,19 @@ RUN echo "max_input_vars = 5000" >> /etc/php/8.2/cli/php.ini
#RUN echo "xdebug.client_host=host.docker.internal" >> /etc/php/8.2/apache2/php.ini #RUN echo "xdebug.client_host=host.docker.internal" >> /etc/php/8.2/apache2/php.ini
#RUN echo "xdebug.client_port=9003" >> /etc/php/8.2/apache2/php.ini #RUN echo "xdebug.client_port=9003" >> /etc/php/8.2/apache2/php.ini
# Starting Apache server
RUN chmod 1777 /tmp RUN chmod 1777 /tmp
# Add necessary packages for adding Python 3 repository and installing curl # Installing Moodle Setting correct acces rules
RUN apt-get update && apt-get install -y curl software-properties-common gnupg2 dirmngr --no-install-recommends #RUN cd /var/www/html && mkdir -p moodle
#RUN mkdir -p ${MOODLE_BASE_DIR}
# Add the repository RUN echo ${MOODLE_BASE_DIR}
RUN add-apt-repository 'deb https://deb.debian.org/debian/dists/trixie/ trixie main' RUN mkdir -p /var/www/html/moodle
WORKDIR ${MOODLE_BASE_DIR}
# Update package lists after adding the repository
RUN apt-get update
# Installing necessary Python dependencies & Flask
RUN apt-get install -y python3-venv python3-pip python3-matplotlib
RUN python3 -m venv /opt/myenv
RUN /opt/myenv/bin/python3 -m pip install --upgrade pip
#RUN /opt/myenv/bin/python3 -m pip install matplotlib Flask torch sklearn-learn
COPY requirements.txt /opt/myenv/
WORKDIR /var/www/html/moodle
RUN /opt/myenv/bin/python3 -m pip install -r /opt/myenv/requirements.txt
RUN /opt/myenv/bin/python3 -m pip install --upgrade setuptools wheel
# Copy the api.py script into the container
COPY api.py /var/www/html/moodle/api.py
COPY install_moodle.sh /var/www/html/moodle/install_moodle.sh
RUN chmod +x /var/www/html/moodle/install_moodle.sh
RUN mkdir -p /asyst
# Download and extract the ASYST archive
#RUN curl -o asyst.zip -L https://transfer.hft-stuttgart.de/gitlab/ulrike.pado/ASYST/-/archive/main/ASYST-main.zip && \
# 7z x asyst.zip -o/asyst && \
# mv /asyst/ASYST-main/* /asyst && \
# rm -rf /asyst/ASYST-main asyst.zip
# Set permissions (if necessary) #RUN #mkdir -p ${MOODLE_BASE_DIR} && \
RUN chown -R www-data:www-data /asyst RUN wget -qO- https://packaging.moodle.org/stable403/moodle-4.3.4.tgz | tar xz -C ${MOODLE_BASE_DIR} --strip-components=1
RUN chmod -R 755 /asyst #RUN wget -qO- https://packaging.moodle.org/stable403/moodle-4.3.4.tgz | tar xz --strip-components=1 -C /var/www/html/moodle
COPY ./asyst /var/www/html/moodle/asyst
RUN ln -s /var/www/html/moodle/asyst/Source/Skript /var/www/html/moodle/Skript
# Installing Moodle Setting correct acces rules
RUN mkdir -p ${MOODLE_BASE_DIR} && \
wget -qO- https://packaging.moodle.org/stable403/moodle-4.3.4.tgz | tar xz -C ${MOODLE_BASE_DIR} --strip-components=1
RUN chown -R www-data:www-data ${MOODLE_BASE_DIR} && \ RUN chown -R www-data:www-data ${MOODLE_BASE_DIR} && \
find ${MOODLE_BASE_DIR} -type d -exec chmod 755 {} \; && \ find ${MOODLE_BASE_DIR} -type d -exec chmod 755 {} \; && \
...@@ -159,10 +127,8 @@ RUN a2enmod ssl ...@@ -159,10 +127,8 @@ RUN a2enmod ssl
#RUN echo "127.0.0.1 ${MOODLE_WWWROOT##https://}" >> /etc/hosts #RUN echo "127.0.0.1 ${MOODLE_WWWROOT##https://}" >> /etc/hosts
#Opening ports #Opening ports
EXPOSE 80 443 5000 #EXPOSE 80 443 5000
EXPOSE 80 443
# Setting up supervisord
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Running supervisord # Running supervisord
CMD ["/usr/bin/supervisord"] CMD ["apache2ctl", "-D", "FOREGROUND"]
...@@ -36,7 +36,6 @@ services: ...@@ -36,7 +36,6 @@ services:
ports: ports:
- 80:80 - 80:80
- 443:443 - 443:443
- 5000:5000
dns: dns:
- 8.8.8.8 - 8.8.8.8
- 8.8.4.4 - 8.8.4.4
...@@ -49,6 +48,22 @@ services: ...@@ -49,6 +48,22 @@ services:
networks: networks:
- network # Adding the network communication between containers - network # Adding the network communication between containers
flask:
build:
context: ./flask # Папка с Dockerfile для Flask
dockerfile: Dockerfile
env_file:
- ./.env
restart: always
ports:
- 5000:5000
volumes:
- ./flask:/app
depends_on:
- mariadb
networks:
- network
volumes: # Defining local volumes volumes: # Defining local volumes
moodledata: moodledata:
driver: local driver: local
...@@ -58,6 +73,8 @@ volumes: # Defining local volumes ...@@ -58,6 +73,8 @@ volumes: # Defining local volumes
driver: local driver: local
asystgrade: asystgrade:
driver: local driver: local
flask:
driver: local
networks: networks:
network: # Creating a network network: # Creating a network
\ No newline at end of file
...@@ -74,14 +74,15 @@ docker-compose exec moodle apt-get update && apt-get install -y locales && \ ...@@ -74,14 +74,15 @@ docker-compose exec moodle apt-get update && apt-get install -y locales && \
sudo chown -R $(whoami):$(whoami) ./asystgrade sudo chown -R $(whoami):$(whoami) ./asystgrade
# Create the run_sag script file # Create the run_sag script file
docker-compose exec moodle bash -c 'cat <<EOF > /usr/local/bin/run_sag docker-compose exec flask bash -c 'cat <<EOF > /usr/local/bin/run_sag
#!/bin/bash #!/bin/bash
. /opt/myenv/bin/activate . /opt/myenv/bin/activate
cd ${MOODLE_BASE_DIR}/asyst/Source/Skript/german #cd ${MOODLE_BASE_DIR}/asyst/Source/Skript/german
/opt/myenv/bin/python3 ${MOODLE_BASE_DIR}/api.py cd /app/asyst/Source/Skript/german
/opt/myenv/bin/python3 /app/api.py
EOF' EOF'
# Make the script executable & run it # Make the script executable & run it
docker-compose exec moodle chmod +x /usr/local/bin/run_sag docker-compose exec flask chmod +x /usr/local/bin/run_sag
docker-compose exec moodle /usr/local/bin/run_sag docker-compose exec flask /usr/local/bin/run_sag
[supervisord]
nodaemon=true
[program:apache2]
command=/usr/sbin/apache2ctl -D FOREGROUND
autostart=true
autorestart=true
stdout_logfile=/var/log/moodle.log
stderr_logfile=/var/log/moodle_err.log
[program:flask]
#command=/bin/bash -c 'source /opt/myenv/bin/activate && FLASK_APP=/var/www/html/moodle/api.py /opt/myenv/bin/flask run --host=0.0.0.0'
command=/bin/bash -c 'source /opt/myenv/bin/activate &&/opt/myenv/bin/python3 /var/www/html/moodle/api.py'
directory=/var/www/html/moodle
autostart=true
autorestart=true
stdout_logfile=/var/log/flask.log
stderr_logfile=/var/log/flask_err.log
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment