Commit 991940bc by Bruno Bzeznik

Now ready to debug (have to fix virtualhost)

parent 7d6f1a12
Creates a nixos-container suitable for developments and testing of phyloalps.
There are 3 parts:
* A nixos configuration, which is the base NixOS system of the container
* A script "init-phylodb-container.sh", to run as root, to launch and configure the container
* A script "store/init.sh" which is called inside the container, this is where most of the phyloalps configuration is done
Usage:
------
* Create the container configuration (as root):
......
......@@ -21,4 +21,5 @@ run mkdir -p /var/lib/phyloalps/phylodb
run cp -a $source_dir/* /var/lib/phyloalps/phylodb/
run mkdir -p /var/lib/phyloalps/phylodb/log
run touch /var/lib/phyloalps/phylodb/log/debug.log
run chown -R phyloalps /var/lib/phyloalps
run bash $init_script
......@@ -4,6 +4,7 @@
{ config =
{ config, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
coreutils
findutils
......@@ -19,9 +20,8 @@
git
(python36.withPackages(ps: with ps; [pip virtualenv psycopg2 urllib3 requests]))
];
networking.nat.enable = true;
services.httpd.enable = true;
services.httpd.adminAddr = "gridmaster@univ-grenoble-alpes.fr";
services.openssh.enable = true;
services.postgresql = {
enable = true;
......@@ -34,6 +34,38 @@
CREATE DATABASE editor_db OWNER phyloalps;
'';
};
users.extraUsers.phyloalps = {
isNormalUser = true;
};
services.httpd = {
enable = true;
package = pkgs.apacheHttpd;
adminAddr = "info@phyloalps.org";
hostName = "phylodb.u-ga.fr";
logPerVirtualHost = true;
extraModules = ["proxy" "proxy_http" "cache"];
virtualHosts = [
{
hostName = "data.phyloalps.org";
documentRoot = "/var/lib/phyloalps/phylodb";
extraConfig = ''
ProxyPassReverse / http://localhost:8888/
RewriteEngine on
RewriteRule ^/\.well-known/?(.*)$ http://data.phyloalps.org/static/%{REQUEST_URI} [L,P]
RewriteRule ^/static/?(.*)$ - [L,P]
RewriteRule ^/(.*)$ http://localhost:8888/$1 [P]
<Directory /static/>
Require all granted
</Directory>
'';
}];
};
system.activationScripts = {
django_init = {
text = ''
......
......@@ -13,6 +13,7 @@ pip install ply
pip install sparqlwrapper
pip install django-debug-toolbar
pip install django-widget-tweaks
pip install -I gunicorn
# Create the postgis extension into DBs (must be superuser)
sudo -u postgres psql -d editor_db -c "CREATE EXTENSION IF NOT EXISTS postgis"
......@@ -27,3 +28,26 @@ python3 manage.py migrate --database=browser_db
# Init the superuser
echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'gridmaster@univ-grenoble-alpes.fr', 'phylodev')" | python3 manage.py shell
# Load sample data
latest_sample=`ls samples/*[0-9].csv|sort -n|tail -1`
sudo -u phyloalps python3 install/load_sampling_data.py $latest_sample browser_db phylobrowser
sudo -u phyloalps python3 install/load_sampling_data.py $latest_sample editor_db phyloeditor
# Reverse geocode the samples GPS coordinates
# TODO: save samples into a file, to by-pass the need of the online Geonames.org api
# sudo -u phyloalps python3 install/reverse_geocode.py browser_db phylobrowser
# sudo -u phyloalps python3 install/reverse_geocode.py editor_db phyloeditor
# Load the genomic data
# TODO: this is very long - Maybe prepare a DB daily outside and load an SQL dump here?
#sudo -u phyloalps python3 install/load_genomic_data.py browser_db phylobrowser
#sudo -u phyloalps python3 install/load_genomic_data.py editor_db phyloeditor
# Copy static files and grant permissions to httpd
python3 manage.py collectstatic
chown -R wwwrun:wwwrun /var/lib/phyloalps/phylodb/static
chmod -R 775 /var/lib/phyloalps/phylodb/static
# Start Gunicon WSGI server on port 8888
nohup gunicorn -b :8888 phylodb.wsgi&
Markdown is supported
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