Installation on amd64 and Debian Jessie
Execute these commands as
root
user
$ echo 'http_proxy=http://<adresse_proxy:port_proxy>; export http_proxy' >> /etc/bash.bashrc
$ echo 'https_proxy=http://<adresse_proxy:port_proxy>; export https_proxy' >> /etc/bash.bashrc
$ echo 'no_proxy="localhost,127.0.0.1,.mondomaine"; export no_proxy' >> /etc/bash.bashrc
$ apt-get install bash-completion openssh-server sudo
$ useradd -c "uData user" -m -s /bin/bash udata
$ passwd udata
$ adduser udata sudo
$ sudo apt-get install mailutils exim4
$ cd /var
$ sudo mkdir myudata
$ sudo chown udata:udata myudata
Execute these commands as
udata
user
$ sudo apt-get install git-core
$ sudo apt-get install build-essential pkg-config python python-dev python-pip \
libjpeg-dev zlib1g-dev libtiff5-dev libfreetype6-dev \
liblcms2-dev libopenjpeg-dev libwebp-dev libpng12-dev \
libxml2-dev libxslt1-dev liblzma-dev libyaml-dev
Install packages to allow apt
to use a repository over HTTPS:
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
Add Docker's official GPG key:
$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
Verify that the key ID is 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
$ sudo apt-key fingerprint 0EBFCD88
pub 4096R/0EBFCD88 2017-02-22
Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid Docker Release (CE deb) <docker@docker.com>
sub 4096R/F273FCD8 2017-02-22
Set up the stable repository for amd64
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
Install the latest version of Docker
$ sudo apt-get update
$ sudo apt-get install docker-ce
Verify that Docker is installed correctly by running the hello-world
image.
$ sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.
We don't want to use sudo
to run Docker commands
$ sudo groupadd docker
$ sudo usermod -aG docker udata
Verify that we can run Docker commands without sudo
$ docker run hello-world
$ sudo systemctl enable docker
Create a systemd drop-in directory for the docker service:
$ mkdir -p /etc/systemd/system/docker.service.d
Create a file called /etc/systemd/system/docker.service.d/http-proxy.conf
that adds the HTTP_PROXY
, HTTPS_PROXY
and NO_PROXY
environment variable:
$ sudo nano /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://<adresse_proxy:port_proxy>/" "HTTPS_PROXY=http://<adresse_proxy:port_proxy>/" "NO_PROXY=localhost,127.0.0.1,.mondomaine"
Flush changes
$ sudo systemctl daemon-reload
Restart Docker
$ sudo systemctl restart docker
Download the Docker Compose binary
sudo -i
curl -L https://github.com/docker/compose/releases/download/1.12.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
exit
Apply executable permissions to the binary
sudo chmod +x /usr/local/bin/docker-compose
Test the installation
docker-compose --version
Execute these commands as
udata
user
Execute these commands in udata directory (
/var/myudata
)
Be careful because we are behind a proxy and with git
$ git config --global http.proxy http://<adresse_proxy:port_proxy>
$ git config --global https.proxy http://<adresse_proxy:port_proxy>
$ git config --global url."https://github.com/".insteadOf git://github.com/
Now we can clone the udata repository
$ git clone https://github.com/opendatateam/udata.git
And go to the udata directory
$ cd udata
Install virtualenv
$ pip install --user virtualenv
Set virtualenv in the path
$ echo 'export PATH=$HOME/.local/bin:$PATH' >> /home/udata/.bashrc
Create a python 2.7 virtualenv for the project
$ virtualenv --python=python2.7 venv
Activate the virtualenv and install the requirements
$ source venv/bin/activate
$ pip install Cython
$ pip install -r requirements/develop.pip
Install the project in editable mode
$ pip install -e .
Install NodeJs
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
$ export NVM_DIR="$HOME/.nvm"
$ [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
$ nvm install
$ nvm use
We are behind a proxy, so:
$ npm config set proxy "http://<adresse_proxy:port_proxy>" -g
$ npm config set https-proxy "http://<adresse_proxy:port_proxy>" -g
Now we can use npm to install packages
$ npm install
Execute these commands as
udata
user
Execute these commands in udata directory (
/var/myudata/udata
) and with venv (source venv/bin/activate
)
$ inv assets_build
clone the repository
$ git clone https://github.com/etalab/udata-gouvfr.git
Install project in editable mode
$ pip install -e udata-gouvfr
install packages via npm
$ npm install
Build JS and CSS for gouvfr theme
$ cd udata-gouvfr
$ inv assets
$ cd ..
First create a transifex account.
Set informations of transifex account in /home/udata/.transifexrc
$ nano /home/udata/.transifexrc
[https://www.transifex.com]
hostname = https://www.transifex.com
password = <transifex-password>
token =
username = <transifex-username>
Fetch last translations and compile translation for udata
$ tx pull
$ inv i18nc
Fetch last translations and compile translation for theme gouvfr
$ cd udata-gouvfr
$ tx pull
$ inv i18nc
$ cd ..
Create udata.cfg
(example here)
nano udata.cfg
Export the UDATA_SETTINGS environment variable each time venv is activate
$ echo "export UDATA_SETTINGS=/var/myudata/udata/udata.cfg" >> venv/bin/activate
$ deactivate
$ source venv/bin/activate
Create Procfile
(example (example here)
In our example we will launc web server, celery workers and the tree dependencies via docker-compose up (MongoDb, Redis and ElasticSearch)
$ nano Procfile
Run all dependencies
$ honcho start
Install apache
$ sudo apt-get install apache2
Install proxy and proxy_http modules for apache
$ sudo a2enmod proxy proxy_http
Create virtualhost for myudata: edit myudata.conf
$ nano /etc/apache2/sites-available/myudata.conf
<virtualhost *:80>
ServerName myhostname.icanresolve.viadns
ProxyPass / http://localhost:7000/
ProxyPassReverse / http://localhost:7000/
ProxyRequests Off
ProxyPreserveHost Off
</virtualhost>
Enable the site and restart apache
$ sudo a2ensite myudata
$ sudo service apache2 restart
With this configuration all requests like http://myhostname.icanresolve.viadns/* will be redirected to http://localhost:7000/* We must change some lines in udata.cfg
$ nano udata.cfg
SERVER_NAME = 'myhostname.icanresolve.viadns'
SITE_URL = 'myhostname.icanresolve.viadns'
Execute these commands as
udata
user
Execute these commands in udata directory (
/var/myudata/udata
), with venv (source venv/bin/activate
) an with project running (honcho start
)
$ udata init
$ udata spatial load https://www.data.gouv.fr/fr/datasets/r/48aed8bc-679b-41a2-80ec-4611d61ca6b9
$ udata licenses https://www.data.gouv.fr/api/1/datasets/licenses
udata user create
udata user set_admin <mail-first-user>
udata metrics update
udata search reindex