Browse Source

Dockerfiles update + misc

francesco 11 months ago
parent
commit
29ef6f06c1
6 changed files with 202 additions and 3 deletions
  1. 0 3
      Dockerfile
  2. 3 0
      flask_be/Dockerfile
  3. 30 0
      readme.md
  4. 6 0
      site2/Dockerfile
  5. 130 0
      site2/js/toExport_alt.js
  6. 33 0
      site2/tigro.conf

+ 0 - 3
Dockerfile

@@ -1,3 +0,0 @@
-FROM httpd:latest
-COPY site2 /usr/local/apache2/htdocs
-EXPOSE 80

+ 3 - 0
flask_be/Dockerfile

@@ -0,0 +1,3 @@
+FROM python:3.11.4-bullseye
+
+EXPOSE 5000

+ 30 - 0
readme.md

@@ -30,3 +30,33 @@ To get flask running (use Python 3, any version should do!):
 - Subfolder 'site2'
 
 To avoid annoying CORS errors, if the PC complains, serve the site through a local server, for instance http-server on node.js
+
+
+
+COMMANDS (most need sudo):
+
+LINUX:
+- lsof  -i:PORT  -->  list processes listening on PORT on linux
+- ss -ltnp  -->  list processes listening on various ports
+- ip a  -->  various machine ips
+- top, nohup  -->  old friends
+- ssh-keygen  -->  generate public/private key pair. TAKE CARE OF THE FORMAT: EGI virtual machines seem to NEED RSA. The public key needs to be saved in /home/USERNAME/.ssh, and to be cat-ed in the /home/USERNAME/.ssh/authorized_keys file. The private key needs to be used by the user wanting to login; on linux, permissions must be 700.
+- journalctl -xe  -->  ???
+
+
+APACHE:
+- systemctl start/stop/restart/reload apache2
+- a2ensite NOMESITO  -->  apache2 command to add 'site' (configuration file NOMESITO.conf in /etc/apache2/sites-available) to sites-enabled
+- a2enmod proxy  -->  command to enable reverse proxy setup in virtualhost (use together with proxy_http)
+- a2enmod proxy_http  -->  command to enable reverse proxy setup in virtualhost (use together with proxy)
+
+
+PYTHON:
+- waitress-serve --listen=127.0.0.42:5000 app:app  -->  example of command to serve flask app (file app.py, app name = app) on the waitress WSGI
+
+
+DOCKER:
+- docker exec -it tigro000 bash  -->  explore Docker image 'tigro000' filesystem (with bash); more generally, docker exec will execute commands on it.
+- docker run -d --name tigro -p 80:80 tigro000  -->  example of running Docker: run image 'tigro000' in container named 'tigro'; expose internal port 80 on external port 80 (-p); detach (-d)
+- docker images  -->  check existing Docker images
+- docker ps  -->  check running docker containers

+ 6 - 0
site2/Dockerfile

@@ -0,0 +1,6 @@
+FROM httpd:latest
+COPY * /usr/local/apache2/htdocs/tigro_website/
+COPY js/toExport_alt.js /usr/local/apache2/htdocs/tigro_website/js/toExport.js
+COPY tigro.conf /etc/apache2/sites-available/
+CMD ["a2ensite", "tigro"]
+EXPOSE 80

+ 130 - 0
site2/js/toExport_alt.js

@@ -0,0 +1,130 @@
+import {processData, processOccData} from './processData.js'
+
+export const flask_be_address = 'http://147.213.76.243/data';
+
+export function getData(endpoint, queryDTO){
+
+    let url = flask_be_address.concat(endpoint);
+
+    // This seems to work and it's definitely better than previous version
+    return $.ajax(
+      {
+        url: url,
+        type: 'POST',
+        contentType: 'application/json; charset=utf-8',
+        dataType: 'json',
+        data: JSON.stringify(queryDTO),
+      }
+    );
+
+}
+
+export let queryDTO = {};
+
+export function funzioneRicerca(){
+    $("#result").html("");
+    $("#loader").css("display", "block");
+    let collection_elementoDaRicercare = document.getElementsByClassName("barraDiRicerca");
+    var collection_types = document.getElementsByClassName("flViewBy");
+    var collection_lenght = collection_elementoDaRicercare.length;
+    let distanza = document.getElementById("distanza").value;
+    let queryList = [];
+    var periodo = 0;
+    var ordinate = 0;
+  
+    var i = 0;
+    for (i; i < collection_lenght; i++) {
+      let elementoDaRicercare = collection_elementoDaRicercare[i].value;
+      let word = elementoDaRicercare;
+      var tipo = "";
+      var espansa = 0;
+      var raddoppiata = 0;
+      var noLemma = 0;
+      var formeLemmi = 0;
+      var check_tipo = collection_types[i].value;
+   
+      //NOLEMMA DEVE ESSERE CONVERTITO IN TIPO (TIPO = 0, 1, 2), TIPO = 2 SE NOLEMMA è SELEZIONATO
+         
+      if ($('#occ_' + i + ' .ricercaEx').prop("checked"))
+      {
+        espansa = 1;
+      }
+      if ($('#occ_' + i + ' .raddoppiata').prop("checked"))
+      {
+        raddoppiata = 1;
+      }
+      if ($('#occ_' + i + ' .showOther').prop("checked"))
+      {
+        formeLemmi = 1;
+      }
+      if ($('#occ_' + i + ' .lemmatizzata').prop("checked"))
+      {
+        noLemma = 1;
+      }
+      
+  
+      if ((check_tipo == "forma") && (formeLemmi == 0)) {
+        tipo = "forma";
+      }
+      else if ((check_tipo == "forma") && (formeLemmi == 1)) {
+        tipo = "formaLemma";
+      }
+      else if ((check_tipo == "lemma") && (noLemma == 1)) {
+        tipo = "soloLemmatizzate";
+      }
+      else if ((check_tipo == "lemma") && (formeLemmi == 0)) {
+        tipo = "lemma";
+      }
+      else if ((check_tipo == "lemma") && (formeLemmi == 1)) {
+        tipo = "lemmaForma";
+      }
+  
+      queryList.push( {"stringa": word, "espansa": espansa, "raddoppiata": raddoppiata, "tipo": tipo} );
+      //$("#params").append("I tuoi parametri: " + word + "; " + tipo + "; " + espansa + "; " + raddoppiata + "; " + formeLemmi);
+    
+    }
+  
+    if ($('#periodo').prop("checked"))
+    {
+      periodo = 1;
+    }
+    if ($('#ordinate').prop("checked"))
+    {
+      ordinate = 1;
+    }
+  
+    let cooccorrenze = {"distanza": distanza, "stesso_periodo": periodo, "ordinate": ordinate};
+  
+    let numb = document.getElementById("search_form").childElementCount;
+    if (numb < 2) {
+        queryDTO = {
+          queryList: queryList
+      }
+      getData('/simple_get_query', queryDTO)
+      // After request finishes, process response data
+      .done(response => processData(response))
+      .fail(err => {
+        console.log(err);
+        $("#loader").css("display", "none");
+        alert('Something went wrong!');
+      });
+    } else {
+        queryDTO = {
+          queryList: queryList,
+          cooccorrenze: cooccorrenze
+      }
+      getData('/simple_get_query', queryDTO)
+      // After request finishes, process response data
+      .done(response => processOccData(response))
+      .fail(err => {
+        console.log(err);
+        $("#loader").css("display", "none");
+        alert('Something went wrong!');
+      });
+    } 
+  
+    console.log(queryDTO);
+  
+    $("#lauchSearchContext").css("display", "flex");
+    
+  } 

+ 33 - 0
site2/tigro.conf

@@ -0,0 +1,33 @@
+<VirtualHost 147.213.76.243:80>
+        # The ServerName directive sets the request scheme, hostname and port that
+        # the server uses to identify itself. This is used when creating
+        # redirection URLs. In the context of virtual hosts, the ServerName
+        # specifies what hostname must appear in the request's Host: header to
+        # match this virtual host. For the default virtual host (this file) this
+        # value is not decisive as it is used as a last resort host regardless.
+        # However, you must set it for any further virtual host explicitly.
+        #ServerName www.example.com
+
+        ServerAdmin webmaster@localhost
+        DocumentRoot /usr/local/apache2/htdocs/tigro_website
+
+        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
+        # error, crit, alert, emerg.
+        # It is also possible to configure the loglevel for particular
+        # modules, e.g.
+        #LogLevel info ssl:warn
+
+        ErrorLog ${APACHE_LOG_DIR}/error.log
+        CustomLog ${APACHE_LOG_DIR}/access.log combined
+
+        # For most configuration files from conf-available/, which are
+        # enabled or disabled at a global level, it is possible to
+        # include a line for only one particular virtual host. For example the
+        # following line enables the CGI configuration for this host only
+        # after it has been globally disabled with "a2disconf".
+        #Include conf-available/serve-cgi-bin.conf
+
+        ProxyPass /data http://127.0.0.42:5000
+        ProxyPassReverse /data http://127.0.0.42:5000
+
+</VirtualHost>