| author | ymh <ymh.work@gmail.com> |
| Thu, 15 Mar 2018 23:52:11 +0100 | |
| changeset 686 | 385e3a12ee27 |
| child 687 | 53fee689f666 |
| permissions | -rw-r--r-- |
|
686
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
# HDALab Docker images |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
- restore database |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
- |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
## Comment construire les container HDALab |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
Toutes les commandes suivantes sont à effectuer dans le répertoire contenant le fichier `docker-compose.yml`. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
$ ./prepare_docker_build.sh |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
$ docker-compose -p hdalab build |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
$ docker-compose -p hdalab up -d |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
$ docker-compose -p hdalab exec hdalab django-admin collectstatic --noinput |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
$ docker-compose -p hdalab exec hdalab django-admin migrate --noinput |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
$ docker-compose -p hdalab exec hdalab supervisorctl restart all |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
Le site est consultable à l'adresse suivante : [http://127.0.0.1:8080](http://127.0.0.1:8080) |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
Le système est fonctionnel mais avec une bases de donnée vide. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
### Création d'un "superuser" |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
Cette commande permet la creation d'un utilisateur administeur de l'application. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
$ docker-compose -p hdalab exec hdalab django-admin createsuperuser |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
### Import des données issues de l'export HDA |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
Cette commande importe les données RDF exportées à partir de l'application HDA. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
Attention cette commande peut être longue. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
$ docker-compose -p hdalab exec hdalab /usr/local/sbin/import_hda_rdf.sh /etc/hdalab/data /var/lib/hdalab http://data.culture.fr/entrepot/HDA/export.tgz |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
38 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
39 |
### Import d'un dump de l'application |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
40 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
41 |
#### Import d'un dump de la base de donnée |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
42 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
43 |
Le fichier de dump de base de données doit être décompressé. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
44 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
45 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
46 |
$ docker-compose -p hdalab stop hdalab |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
47 |
$ docker exec -i hdalab_pg_1 psql -U iri postgres < </chemin/du/fichier/dump/sql.bckp> |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
48 |
$ docker-compose -p hdalab start hdalab |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
49 |
$ docker-compose -p hdalab exec hdalab django-admin migrate --noinput |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
50 |
$ echo "from django.contrib.sites.models import Site; site=Site.objects.all()[0]; site.domain='127.0.0.1:8080'; site.name='HDALab'; site.save()" | docker exec -i hdalab_hdalab_1 django-admin shell |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
51 |
$ docker-compose -p hdalab exec hdalab django-admin changepassword admin |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
52 |
$ docker-compose -p hdalab exec hdalab django-admin rebuild_index --noinput |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
53 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
54 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
55 |
#### Import des miniatures renkan |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
56 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
57 |
Ces commandes supposent que le service `hdalab` est actif. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
58 |
L'archive comprenant l'export des miniatures doit être décompressé. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
59 |
Cette archive contient le répertoire `media` à la racine |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
60 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
61 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
62 |
$ docker cp ./media/. hdalab_hdalab_1:/var/lib/hdalab/static/media |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
63 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
64 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
65 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
66 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
67 |
# Commandes utiles |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
68 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
69 |
## liste des services |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
70 |
Les services suivants sont définis dans le fichier `docker-compose.yml`: |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
71 |
- pg : La base de donnée postgresql |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
72 |
- es : ElasticSearch |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
73 |
- mail : Mailhog, fourni un serveur smtp de test |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
74 |
- front : Le serveur web (nginx) |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
75 |
- hdalab : application hdalab comprenant l'application web elle-même et les services associés (envoi de mail et calcul des preevisualisations Renkan) |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
76 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
77 |
## Démarrage des services |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
78 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
79 |
Les services se contrôlent avec la commande `docker-compose`. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
80 |
La ligne de commande typique est la suivante: |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
81 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
82 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
83 |
$ docker-compose [-f </path/to/docker-compose.yml>] -p hdalab [COMMAND] [ARGS...] |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
84 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
85 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
86 |
Il faut bien noter l'utilisation systématique de l'option `-p hdalab` qui spécifie le nom du projet. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
87 |
Si la commande est lancée dans le même répertoire que celui du fichier `docker-compose.yml` l'option `-f` peut être ignorée. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
88 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
89 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
90 |
## Construction des images des conteneurs |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
91 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
92 |
$ docker-compose [-f </path/to/docker-compose.yml>] -p hdalab build [SERVICE...] |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
93 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
94 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
95 |
## création et lancement des services |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
96 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
97 |
$ docker-compose [-f </path/to/docker-compose.yml>] -p hdalab up -d [SERVICE...] |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
98 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
99 |
A noter l'option `-d` qui mettent les services en tache de fond. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
100 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
101 |
## lancement des services |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
102 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
103 |
$ docker-compose [-f </path/to/docker-compose.yml>] -p hdalab run SERVICE [COMMAND] [ARGS...] |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
104 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
105 |
Cette commande lance un service. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
106 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
107 |
## Execution d'une commande sur un service lancé |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
108 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
109 |
$ docker-compose [-f </path/to/docker-compose.yml>] -p hdalab exec SERVICE COMMAND [ARGS...] |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
110 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
111 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
112 |
## arrêt des services |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
113 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
114 |
$ docker-compose [-f </path/to/docker-compose.yml>] -p hdalab stop [SERVICE...] |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
115 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
116 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
117 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
118 |
## consulter la sortie des containers |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
119 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
120 |
$ docker-compose [-f </path/to/docker-compose.yml>] -p hdalab logs [-f] [SERVICE...] |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
121 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
122 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
## effacement et recréation de la base de donnée vide |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
124 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
125 |
Attention, toutes les données de la base seront définitivement supprimées. |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
|
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
127 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
128 |
$ docker-compose [-f </path/to/docker-compose.yml>] -p hdalab stop hdalab |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
129 |
$ echo "drop database hdalab;\ncreate database hdalab owner iri encoding 'utf-8';" | docker exec -i hdalab_pg_1 psql -U iri postgres |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
130 |
``` |
|
385e3a12ee27
Containerization and various corrections to make it work
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
131 |