diff --git a/.dockerignore b/.dockerignore index bfb164d..8b2d2d7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,23 @@ +.DS_Store +__pycache__ +*.pyc +.git +.gitignore +config.py ksi-py3-venv +.ipynb_checkpoints + +.idea + +build/* +*_build/*.html +*_build/archived/* + +.env +*.secret + +!**/.gitkeep +!**/index.html + +docker-compose.yaml +docker/Dockerfile diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 0000000..ce16ba4 --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,33 @@ +name: Docker Compose Build and Push + +on: + push: + branches: + - main + - master + +jobs: + build_and_push: + runs-on: ubuntu-latest + + steps: + - name: Check out the repository, including submodules + uses: actions/checkout@v3 + with: + submodules: recursive + path: web + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker images + working-directory: ./web + run: | + docker compose build + docker compose push diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 08a9bdc..0000000 --- a/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM ubuntu:18.04 - -RUN apt update -RUN apt install -y python3 python3-dev python3-pip python3-venv libmysqlclient-dev gcc # make - -# RUN pip3 install jupyter wheel - -EXPOSE 8080 -WORKDIR /myapp - -COPY requirements_3.6.lock.txt ./ - -RUN pip3 install -r requirements_3.6.lock.txt - -COPY ./ /myapp - -# run ember server on container start -ENTRYPOINT ["jupyter"] -CMD ["notebook", "--no-browser", "--ip=0.0.0.0", "--port=8080", "--allow-root"] diff --git a/Makefile b/Makefile index b53d405..80ab387 100644 --- a/Makefile +++ b/Makefile @@ -1,32 +1,11 @@ -KSI_TARGETS=$(patsubst notebooks/%.ipynb, ksi_build/%.html, $(wildcard notebooks/*.ipynb)) -NASKOC_TARGETS=$(patsubst notebooks/%.ipynb, naskoc_build/%.html, $(wildcard notebooks/*.ipynb)) -DOCKER_TARGETS=$(patsubst notebooks/%.ipynb, docker_build/%.html, $(wildcard notebooks/*.ipynb)) +TARGETS=$(patsubst notebooks/%.ipynb, build/%.html, $(wildcard notebooks/*.ipynb)) -ksi: $(KSI_TARGETS) -naskoc: $(NASKOC_TARGETS) -docker: $(DOCKER_TARGETS) -all: $(KSI_TARGETS) $(NASKOC_TARGETS) +all: $(TARGETS) -include .env - -# Note: Race condition on file db_uri.secret - -ksi_build/%.html: notebooks/%.ipynb - echo $(DB_URI_KSI) > db_uri.secret - ksi-py3-venv/bin/python3 export_monitoring_notebook $< $@ - rm db_uri.secret || true - -naskoc_build/%.html: notebooks/%.ipynb - echo $(DB_URI_NASKOC) > db_uri.secret - ksi-py3-venv/bin/python3 export_monitoring_notebook $< $@ - rm db_uri.secret || true - -docker_build/%.html: notebooks/%.ipynb +build/%.html: notebooks/%.ipynb python3 export_monitoring_notebook $< $@ clean: - rm -rf $(KSI_TARGETS) - rm -rf $(NASKOC_TARGETS) rm -rf $(DOCKER_TARGETS) .PHONY: all clean diff --git a/ksi_build/custom.css b/build/custom.css similarity index 100% rename from ksi_build/custom.css rename to build/custom.css diff --git a/ksi_build/index.html b/build/index.html similarity index 100% rename from ksi_build/index.html rename to build/index.html diff --git a/ksi_build/style.css b/build/style.css similarity index 100% rename from ksi_build/style.css rename to build/style.css diff --git a/config.py.sample b/config.py.sample new file mode 100644 index 0000000..f87f7b2 --- /dev/null +++ b/config.py.sample @@ -0,0 +1 @@ +SQL_ALCHEMY_URI = 'mariadb+pymysql://user:password@server/db?charset=utf8mb4' diff --git a/docker-compose.yml b/docker-compose.yml index ed96e64..3955290 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,16 @@ version: '2' services: - dashboardbuild: - build: . + ksi-dashboard: + build: + context: . + dockerfile: docker/Dockerfile + container_name: ksi-dashboard + image: fi0ksi/ksi-dashboard volumes: - # - ./:/myapp - - ./docker_build:/myapp/docker_build - ports: - - "8080:8080" - # entrypoint: /myapp/build_in_docker.sh - - # If you want manual bash, do the following. - # 1. Uncomment the following line: - # entrypoint: tail -f /dev/null # Uncomment this if you want to start bash manually after the - # 2. Do `docker-compose up -d --build` - # 3. After it finishes, run `docker exec -it web-frontend_ember_1 /bin/bash` + - ./build:/myapp/build + - ./config.py:/myapp/config.py:ro + # ports: + # - "127.0.0.1:8080:8080" + entrypoint: /bin/bash + command: /myapp/docker/build_in_docker.sh diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..04b10e3 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.9 + +RUN pip3 install jupyter==1.0.0 wheel setuptools notebook==6.4.11 + +EXPOSE 8080 +WORKDIR /myapp + +COPY requirements.txt ./ + +RUN pip3 install -r requirements.txt + +COPY ./ /myapp + +# run ember server on container start +ENTRYPOINT ["jupyter"] +CMD ["notebook", "--no-browser", "--ip=0.0.0.0", "--port=8080", "--allow-root"] diff --git a/build_in_docker.sh b/docker/build_in_docker.sh similarity index 52% rename from build_in_docker.sh rename to docker/build_in_docker.sh index 67b5916..9b11942 100644 --- a/build_in_docker.sh +++ b/docker/build_in_docker.sh @@ -4,5 +4,4 @@ set -e cd /myapp -make clean -make docker_all +make all diff --git a/kleobis-deploy.sh b/kleobis-deploy.sh deleted file mode 100755 index fe893e2..0000000 --- a/kleobis-deploy.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -set -xuo pipefail -cd "$(dirname "$(realpath "$0")")" - -git fetch origin -git reset --hard origin/master - -make clean -# Run as www-data to prevent vulnerabilities possible spread -sudo -Hu www-data make all -j 1 && # don't use higher -j than 1, otherwise race condition -curl --silent https://status.ahlava.cz/api/push/u44pwYohQ2 > /dev/null diff --git a/ksi_build/.gitkeep b/ksi_build/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/ksi_build/.htaccess b/ksi_build/.htaccess deleted file mode 100644 index ee25a8e..0000000 --- a/ksi_build/.htaccess +++ /dev/null @@ -1,11 +0,0 @@ - - Options +ExecCGI - AddHandler cgi-script .sh - AuthType Basic - AuthName "Restricted Content!" - AuthUserFile /etc/apache2/.htpasswd - Require valid-user - - -Header always unset Content-Security-Policy -Header always unset Content-Security-Policy-Report-Only diff --git a/ksi_build/deploy.sh b/ksi_build/deploy.sh deleted file mode 100644 index 5b9de33..0000000 --- a/ksi_build/deploy.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -export LC_ALL=C.UTF-8 - -echo -e "Content-type: text/html\n" - -OUTPUT+=$(cd .. && ./kleobis-deploy.sh 2>&1)$'\n\n' -echo "$OUTPUT" | mail "ksi-admin@fi.muni.cz" -s "[ksi-monitoring] Deploy status" diff --git a/naskoc_build/.gitkeep b/naskoc_build/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/naskoc_build/.htaccess b/naskoc_build/.htaccess deleted file mode 100644 index ee25a8e..0000000 --- a/naskoc_build/.htaccess +++ /dev/null @@ -1,11 +0,0 @@ - - Options +ExecCGI - AddHandler cgi-script .sh - AuthType Basic - AuthName "Restricted Content!" - AuthUserFile /etc/apache2/.htpasswd - Require valid-user - - -Header always unset Content-Security-Policy -Header always unset Content-Security-Policy-Report-Only diff --git a/naskoc_build/custom.css b/naskoc_build/custom.css deleted file mode 100644 index e69de29..0000000 diff --git a/naskoc_build/deploy.sh b/naskoc_build/deploy.sh deleted file mode 100644 index 5b9de33..0000000 --- a/naskoc_build/deploy.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -export LC_ALL=C.UTF-8 - -echo -e "Content-type: text/html\n" - -OUTPUT+=$(cd .. && ./kleobis-deploy.sh 2>&1)$'\n\n' -echo "$OUTPUT" | mail "ksi-admin@fi.muni.cz" -s "[ksi-monitoring] Deploy status" diff --git a/naskoc_build/index.html b/naskoc_build/index.html deleted file mode 100644 index f551a6a..0000000 --- a/naskoc_build/index.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - Naskoč monitoring - - -

Naskoč monitoring

- - - - diff --git a/naskoc_build/style.css b/naskoc_build/style.css deleted file mode 100644 index e1f43fd..0000000 --- a/naskoc_build/style.css +++ /dev/null @@ -1,22 +0,0 @@ -body { - font-family: sans-serif; - max-width: 800px; - min-width: 200px; - margin: auto; - padding-left: 20px; - padding-right: 20px; -} - -a:hover { - text-decoration: none; - color: red; -} - -#logo { - float:right; -} - -strong { - font-weight: bold; - text-decoration: underline; -} diff --git a/requirements.txt b/requirements.txt index 5a78468..ec19d06 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,15 +1,11 @@ # This is aimed at Python 3.9 - -# requires to run first: python3 -m pip install wheel setuptools - -jinja2<3.1 +jinja2==3.0.3 jupyter-client==6.1.12 - -jupyter -matplotlib -sqlalchemy -pandas -seaborn -numpy -mysqlclient -hide-code +jupyter==1.0.0 +matplotlib==3.5.2 +sqlalchemy==1.4.36 +pandas==1.4.2 +seaborn==0.11.2 +numpy==1.22.3 +hide-code==0.6.0 +PyMySQL==1.1.1 diff --git a/requirements_3.6.lock.txt b/requirements_3.6.lock.txt deleted file mode 100644 index d03ac62..0000000 --- a/requirements_3.6.lock.txt +++ /dev/null @@ -1,66 +0,0 @@ -jupyter==1.0.0 -attrs==19.3.0 -backcall==0.1.0 -bleach==3.1.4 -cycler==0.10.0 -decorator==4.4.2 -defusedxml==0.6.0 -entrypoints==0.3 -importlib-metadata==1.6.0 -ipykernel==5.2.0 -ipython==7.13.0 -ipython-genutils==0.2.0 -ipywidgets==7.5.1 -jedi==0.16.0 -Jinja2==2.11.1 -jsonschema==3.2.0 -jupyter-client==6.1.2 -jupyter-console==6.1.0 -jupyter-contrib-core==0.3.3 -jupyter-contrib-nbextensions==0.5.1 -jupyter-core==4.6.3 -jupyter-highlight-selected-word==0.2.0 -jupyter-latex-envs==1.4.6 -jupyter-nbextensions-configurator==0.4.1 -kiwisolver==1.1.0 -lxml==4.5.0 -MarkupSafe==1.1.1 -matplotlib==3.2.1 -mistune==0.8.4 -mysqlclient==1.4.6 -nbconvert==5.6.1 -nbformat==5.0.4 -notebook==6.0.3 -numpy==1.18.2 -pandas==1.0.3 -pandocfilters==1.4.2 -parso==0.6.2 -pdfkit==0.6.1 -pexpect==4.8.0 -pickleshare==0.7.5 -prometheus-client==0.7.1 -prompt-toolkit==3.0.5 -ptyprocess==0.6.0 -Pygments==2.6.1 -pyparsing==2.4.6 -pyrsistent==0.16.0 -python-dateutil==2.8.1 -pytz==2019.3 -PyYAML==5.3.1 -pyzmq==19.0.0 -qtconsole==4.7.2 -QtPy==1.9.0 -scipy==1.4.1 -seaborn==0.10.0 -Send2Trash==1.5.0 -six==1.14.0 -SQLAlchemy==1.3.24 -terminado==0.8.3 -testpath==0.4.4 -tornado==6.0.4 -traitlets==4.3.3 -wcwidth==0.1.9 -webencodings==0.5.1 -widgetsnbextension==3.5.1 -zipp==3.1.0 -# hide-code==0.5.5 # for some reason this needs to happen only after this requirements.txt is succesfully installed \ No newline at end of file diff --git a/requirements_3.9.lock.txt b/requirements_3.9.lock.txt deleted file mode 100644 index b0cc436..0000000 --- a/requirements_3.9.lock.txt +++ /dev/null @@ -1,70 +0,0 @@ -argon2-cffi==21.3.0 -argon2-cffi-bindings==21.2.0 -attrs==21.4.0 -backcall==0.2.0 -bleach==5.0.0 -cffi==1.15.0 -cycler==0.11.0 -debugpy==1.6.0 -decorator==5.1.1 -defusedxml==0.7.1 -entrypoints==0.4 -fastjsonschema==2.15.3 -fonttools==4.33.3 -greenlet==1.1.2 -hide-code==0.6.0 -ipykernel==6.4.2 -ipython==7.33.0 -ipython-genutils==0.2.0 -ipywidgets==7.7.0 -jedi==0.18.1 -Jinja2==3.0.3 -jsonschema==4.5.1 -jupyter==1.0.0 -jupyter-client==6.1.12 -jupyter-console==6.4.2 -jupyter-core==4.10.0 -jupyterlab-widgets==1.1.0 -kiwisolver==1.4.2 -MarkupSafe==2.1.1 -matplotlib==3.5.2 -matplotlib-inline==0.1.3 -mistune==0.8.4 -mysqlclient==2.1.0 -nbconvert==5.6.1 -nbformat==5.3.0 -nest-asyncio==1.5.5 -notebook==6.4.11 -numpy==1.22.3 -packaging==21.3 -pandas==1.4.2 -pandocfilters==1.5.0 -parso==0.8.3 -pdfkit==1.0.0 -pexpect==4.8.0 -pickleshare==0.7.5 -Pillow==10.0.1 -prometheus-client==0.14.1 -prompt-toolkit==3.0.29 -ptyprocess==0.7.0 -pycparser==2.21 -Pygments==2.12.0 -pyparsing==3.0.9 -pyrsistent==0.18.1 -python-dateutil==2.8.2 -pytz==2022.1 -pyzmq==23.0.0 -qtconsole==5.3.0 -QtPy==2.1.0 -scipy==1.8.1 -seaborn==0.11.2 -Send2Trash==1.8.0 -six==1.16.0 -SQLAlchemy==1.4.36 -terminado==0.15.0 -testpath==0.6.0 -tornado==6.1 -traitlets==4.3.3 -wcwidth==0.2.5 -webencodings==0.5.1 -widgetsnbextension==3.6.0 \ No newline at end of file diff --git a/requirements_3.9.txt b/requirements_3.9.txt deleted file mode 100644 index fbf0013..0000000 --- a/requirements_3.9.txt +++ /dev/null @@ -1,12 +0,0 @@ -# requires to run first: python3 -m pip install wheel setuptools - -jinja2<3.1 -jupyter-client==6.1.12 -jupyter -matplotlib -sqlalchemy -pandas -seaborn -numpy -mysqlclient -hide-code