Commit 7056e2913b65561bf4a4e6c9a095c4c8c3d1502f
1 parent
a68aedba
Exists in
master
dachs logs volumes binded for awstats
Showing
11 changed files
with
51 additions
and
221 deletions
Show diff stats
README deleted
@@ -1,181 +0,0 @@ | @@ -1,181 +0,0 @@ | ||
1 | -# les choses à configurer pour son instance gavo.rc car il y a l'ip du serveur ou son nom dns | ||
2 | -# le nom du dépot correspnd au nom du projet/nom du serveur, ici /vespa/voparis-tap-planeto/ | ||
3 | - | ||
4 | -#Configuration du docker mydachs une fois lancé | ||
5 | -apt-get update | ||
6 | -apt-get upgrade | ||
7 | -apt-get install apache2 | ||
8 | -apt-get install awstats | ||
9 | -apt-get install geoip-database | ||
10 | -apt-get install libgeo-ipfree-perl | ||
11 | -apt-get install git | ||
12 | -apt-get install wget | ||
13 | - | ||
14 | -cd /home/dachsroot/ | ||
15 | -git clone https://gitlab.obspm.fr/vespa/dachs/servers/padc/voparis-tap-planeto.git | ||
16 | -$chemin=/home/dachsroot/nom_du_serveur/ | ||
17 | - | ||
18 | -# sous root configuration du serveur | ||
19 | -cp chemin/conf/000-default.conf /etc/apache2/sites-enabled/000-default.conf | ||
20 | -service apache2 restart | ||
21 | -# restart d'apache pour éviter le conflit de port, apache sera sur le port 8080 | ||
22 | - | ||
23 | -cp chemin/conf/awstats.dachs.conf /etc/awstats/awstats.dachs.conf | ||
24 | -a2enmod cgi | ||
25 | -service apache2 restart | ||
26 | - | ||
27 | -cp chemin/conf/gavo.rc /etc/gavo.rc | ||
28 | -cp chemin/conf/defaultmeta.txt | ||
29 | -chown dachsroot:gavo /var/gavo/etc/defaultmeta.txt | ||
30 | -cp chemin/conf/logo* /var/gavo/web/nv_static/img/ | ||
31 | -chown dachsroot:gavo /var/gavo/web/nv_static/img/logo* | ||
32 | - | ||
33 | - | ||
34 | - | ||
35 | -# sous root configuration des services | ||
36 | -cp -r chemin/services/ /var/gavo/inputs/ | ||
37 | -chown -R dachsroot:gavo /var/gavo/inputs/* | ||
38 | - | ||
39 | -#ingestion des données et création des services | ||
40 | -#depuis chacun des sous répertoires de services | ||
41 | -$sous_rep = nom_sous_repertoire (ici planets seulement) | ||
42 | - | ||
43 | -# pour chaque service | ||
44 | -su -u dachsroot 'gavo imp /var/gavo/inputs/sous_rep/q.rd | ||
45 | -su -u dachsroot 'gavo pub //services' | ||
46 | -su -u dachsroot 'gavo pub //tap' | ||
47 | -su -u dachsroot 'gavo pub /var/gavo/inputs/sous_rep/q.rd' | ||
48 | -gavo serve restart | ||
49 | - | ||
50 | - | ||
51 | -## mettre en cron.daily un fichier en 777 avec | ||
52 | - #!/bin/bash | ||
53 | - /usr/bin/perl /usr/lib/cgi-bin/awstats.pl -config=dachs -update | ||
54 | - | ||
55 | - | ||
56 | - | ||
57 | -## truc à penser | ||
58 | -FROM debian:latest | ||
59 | -RUN apt-get -y update | ||
60 | -RUN apt-get -y install awstats | ||
61 | -RUN apt-get -y install apache2 | ||
62 | -EXPOSE 80 | ||
63 | - | ||
64 | - | ||
65 | - | ||
66 | -########################### | ||
67 | -#help.mdwn : | ||
68 | -########################### | ||
69 | -#source | ||
70 | -https://docs.docker.com/compose/compose-file/ | ||
71 | - | ||
72 | -# packet docker necessaire sur le serveur (deb 10) | ||
73 | -sudo apt install docker docker.io wmdocker | ||
74 | - | ||
75 | -# commande nettoyage pour test | ||
76 | -docker stop dachs-voparis && docker rm dachs-voparis && docker image rm dachs-voparis:latest && docker system prune | ||
77 | - | ||
78 | -#fonctionnement du docker | ||
79 | -dans l'ordre | ||
80 | -.env => définis les variables utilisé dans docker-compose.yml | ||
81 | -docker-compose.yml => définis les dockers et les params de build des bulles | ||
82 | -dachs-dockerfile => définis les lignes de commandes pour build dachs | ||
83 | -docker-entrypoint.sh => script executé au démarrage du docker | ||
84 | -secrets / id_rsa-phamy.prive ==> Ne JAMAIS mettre dans un git !!! | ||
85 | - | ||
86 | -docker-compose up -d ==> lance la séquence, --build pour forcer la maj | ||
87 | - | ||
88 | -docker image list => list les images | ||
89 | -docker ps -a => list les dockers | ||
90 | -docker image rm rep_dachs pour supprimer l'image docker | ||
91 | -docker rm dachs pour supprimer le docker | ||
92 | - | ||
93 | -# link de docker | ||
94 | -si besoin de séparer awstat | ||
95 | -Ne pas utiliser link "depreciate" | ||
96 | - | ||
97 | -version: "3" | ||
98 | -services: | ||
99 | - | ||
100 | - proxy: | ||
101 | - build: ./proxy | ||
102 | - networks: | ||
103 | - - frontend | ||
104 | - app: | ||
105 | - build: ./app | ||
106 | - networks: | ||
107 | - - frontend | ||
108 | - - backend | ||
109 | - db: | ||
110 | - image: postgres | ||
111 | - networks: | ||
112 | - - backend | ||
113 | - | ||
114 | -networks: | ||
115 | - frontend: | ||
116 | - # Use a custom driver | ||
117 | - driver: custom-driver-1 | ||
118 | - backend: | ||
119 | - # Use a custom driver which takes special options | ||
120 | - driver: custom-driver-2 | ||
121 | - driver_opts: | ||
122 | - foo: "1" | ||
123 | - bar: "2" | ||
124 | - | ||
125 | -# volume data | ||
126 | -ajouter dans le yaml docker-compose | ||
127 | -version: "3" | ||
128 | -services: | ||
129 | - | ||
130 | - db: | ||
131 | - image: postgres:13 | ||
132 | - volumes: | ||
133 | - - db-data:/var/lib/postgresql/data | ||
134 | - networks: | ||
135 | - - backend | ||
136 | - | ||
137 | -networks: | ||
138 | - frontend: | ||
139 | - | ||
140 | -volumes: | ||
141 | - db-data: | ||
142 | - | ||
143 | -# passage de variable dans un docker-compose | ||
144 | -Beside your docker-compose.yml file, create a new text file called .env. In it, add the following: | ||
145 | -cat .env | ||
146 | -CLIENT_ID=yourclientid | ||
147 | -CLIENT_SECRET=yourclientsecret | ||
148 | - | ||
149 | -Now, open your docker-compose.yml file again, and replace yourclientid with ${CLIENT_ID} and yourclientsecret with ${CLIENT_SECRET}. That is: | ||
150 | - | ||
151 | -services: | ||
152 | - app: | ||
153 | - . . . #snipped | ||
154 | - environment: | ||
155 | - - GITHUB_CLIENT_ID=${CLIENT_ID} | ||
156 | - - GITHUB_CLIENT_SECRET=${CLIENT_SECRET} | ||
157 | - | ||
158 | -# comment passer des mots des passes | ||
159 | -version: "3.7" | ||
160 | -services: | ||
161 | - | ||
162 | - dachs: | ||
163 | - container_name: dachs-voparis | ||
164 | - image: dachs-voparis | ||
165 | - build: | ||
166 | - dockerfile: dachs-dockerfile | ||
167 | - secrets: | ||
168 | - - id_rsa | ||
169 | - | ||
170 | -secrets: | ||
171 | - id_rsa: | ||
172 | - file: id_rsa-phamy.prive | ||
173 | - | ||
174 | -pour chaque docker dont le secrets id_rsa sera défini, le fichier sera copie dans le docker dans /run/secrets/id_rsa | ||
175 | -root@c459f2b03173:~# ls -tralh /run/secrets/ | ||
176 | -total 16K | ||
177 | --rw-r--r-- 1 dachsroot gavo 739 Nov 24 08:43 id_rsa | ||
178 | ---> sans docker swarm les droits sont ceux de l'hote ! | ||
179 | - | ||
180 | - | ||
181 | - |
.env renamed to conf/.env
@@ -13,8 +13,10 @@ APACHE_PORT=8081 | @@ -13,8 +13,10 @@ APACHE_PORT=8081 | ||
13 | #default 8080 | 13 | #default 8080 |
14 | SERVERNAME=localhost | 14 | SERVERNAME=localhost |
15 | #name of the host machine - default to localhost, for dev | 15 | #name of the host machine - default to localhost, for dev |
16 | -#DOMAIN=`` | 16 | +DOMAIN= |
17 | #default to "" | 17 | #default to "" |
18 | +PROTOCOL=http | ||
19 | +#default to http | ||
18 | 20 | ||
19 | #note the default ports inside the container will be binded to DACHS_PORT and AWSTATS_PORT of the host machine | 21 | #note the default ports inside the container will be binded to DACHS_PORT and AWSTATS_PORT of the host machine |
20 | 22 |
000-default.conf renamed to conf/000-default.conf
awstats.dachs.conf renamed to conf/awstats.dachs.conf
@@ -50,7 +50,6 @@ | @@ -50,7 +50,6 @@ | ||
50 | # | 50 | # |
51 | LogFile="/usr/share/awstats/tools/logresolvemerge.pl /var/gavo/logs/web.log* |" | 51 | LogFile="/usr/share/awstats/tools/logresolvemerge.pl /var/gavo/logs/web.log* |" |
52 | 52 | ||
53 | - | ||
54 | # Enter the log file type you want to analyze. | 53 | # Enter the log file type you want to analyze. |
55 | # Possible values: | 54 | # Possible values: |
56 | # W - For a web log file | 55 | # W - For a web log file |
dachs-dockerfile renamed to conf/dachs-dockerfile
@@ -9,6 +9,9 @@ ARG HOMEPATH=/home/dachsroot | @@ -9,6 +9,9 @@ ARG HOMEPATH=/home/dachsroot | ||
9 | ARG DACHS_PORT | 9 | ARG DACHS_PORT |
10 | ARG APACHE_PORT | 10 | ARG APACHE_PORT |
11 | ARG SERVERNAME | 11 | ARG SERVERNAME |
12 | +ARG DOMAIN | ||
13 | +ARG PROTOCOL | ||
14 | + | ||
12 | 15 | ||
13 | 16 | ||
14 | RUN apt-get -y update | 17 | RUN apt-get -y update |
@@ -26,7 +29,7 @@ RUN echo "deb http://vo.ari.uni-heidelberg.de/debian release main" > /etc/apt/so | @@ -26,7 +29,7 @@ RUN echo "deb http://vo.ari.uni-heidelberg.de/debian release main" > /etc/apt/so | ||
26 | RUN apt-get -y update | 29 | RUN apt-get -y update |
27 | RUN apt-get -y upgrade | 30 | RUN apt-get -y upgrade |
28 | RUN apt-get install -y postgresql-13 postgresql-13-q3c postgresql-13-pgsphere | 31 | RUN apt-get install -y postgresql-13 postgresql-13-q3c postgresql-13-pgsphere |
29 | -RUN apt-get install -y git wget awstats net-tools vim | 32 | +RUN apt-get install -y git wget awstats net-tools vim libgeo-ipfree-perl |
30 | RUN service postgresql restart && apt-get install -y gavodachs2-server | 33 | RUN service postgresql restart && apt-get install -y gavodachs2-server |
31 | RUN apt-get install -y openssh-server openssh-client apache2 w3m | 34 | RUN apt-get install -y openssh-server openssh-client apache2 w3m |
32 | 35 | ||
@@ -35,7 +38,7 @@ RUN apt-get install -y openssh-server openssh-client apache2 w3m | @@ -35,7 +38,7 @@ RUN apt-get install -y openssh-server openssh-client apache2 w3m | ||
35 | COPY . $HOMEPATH | 38 | COPY . $HOMEPATH |
36 | 39 | ||
37 | #import dachs server configuration files from git | 40 | #import dachs server configuration files from git |
38 | -RUN echo $GITURL/vespa/dachs/servers/$GITREPO_INSTITUTION/$GITREPO_SERVER.git | 41 | +RUN echo cloning from $GITURL/vespa/dachs/servers/$GITREPO_INSTITUTION/$GITREPO_SERVER.git |
39 | RUN git clone $GITURL/vespa/dachs/servers/$GITREPO_INSTITUTION/$GITREPO_SERVER.git $HOMEPATH/server | 42 | RUN git clone $GITURL/vespa/dachs/servers/$GITREPO_INSTITUTION/$GITREPO_SERVER.git $HOMEPATH/server |
40 | 43 | ||
41 | 44 | ||
@@ -58,24 +61,44 @@ RUN mkdir $HOMEPATH/services/ && cd $HOMEPATH/services/ && egrep -o 'https://[^" | @@ -58,24 +61,44 @@ RUN mkdir $HOMEPATH/services/ && cd $HOMEPATH/services/ && egrep -o 'https://[^" | ||
58 | RUN cp -r $HOMEPATH/services/* /var/gavo/inputs/ | 61 | RUN cp -r $HOMEPATH/services/* /var/gavo/inputs/ |
59 | 62 | ||
60 | #extract parameters values from gavo.rc | 63 | #extract parameters values from gavo.rc |
64 | +###### | ||
65 | +#replace infos into 000default.conf, awstats.dachs.conf, ports.conf | ||
66 | +###### | ||
61 | 67 | ||
68 | +##Adapt 000-default.conf ports and maintainer (taken from gavo.rc) | ||
62 | RUN export maintainerAddress=`grep "^maintainerAddress:" /etc/gavo.rc | cut -d ":" -f 2` && sed -i "s/webmaster@localhost/${maintainerAddress}/g" /etc/apache2/sites-enabled/000-default.conf && less /etc/apache2/sites-enabled/000-default.conf | 69 | RUN export maintainerAddress=`grep "^maintainerAddress:" /etc/gavo.rc | cut -d ":" -f 2` && sed -i "s/webmaster@localhost/${maintainerAddress}/g" /etc/apache2/sites-enabled/000-default.conf && less /etc/apache2/sites-enabled/000-default.conf |
63 | -RUN sed -i "s/80/${APACHE_PORT}/g" /etc/apache2/ports.conf | ||
64 | RUN sed -i "s/8080/${APACHE_PORT}/g" /etc/apache2/sites-enabled/000-default.conf | 70 | RUN sed -i "s/8080/${APACHE_PORT}/g" /etc/apache2/sites-enabled/000-default.conf |
65 | -RUN sed -i "/serverPort/c\serverPort:${DACHS_PORT}" /etc/gavo.rc | ||
66 | -RUN sed -i "/serverURL/c\serverURL:${SERVERNAME}" /etc/gavo.rc | ||
67 | 71 | ||
68 | -#replace infos into 000default.conf, awstats.dachs.conf, ports.conf | ||
69 | -#RUN sed -i "s/webmaster@localhost/${maintainerAddress}/g" /etc/apache2/sites-enabled/000-default.conf | 72 | +##Adapt ports.conf with APACHE PORT |
73 | +RUN sed -i "s/80/${APACHE_PORT}/g" /etc/apache2/ports.conf | ||
70 | 74 | ||
75 | +##Adapt awstats.dachs.conf with server address and domain | ||
76 | +RUN if [ "$SERVERNAME" = "localhost" ]; then \ | ||
77 | + sed -i "s/mydomain/localhost/g" /etc/awstats/awstats.dachs.conf && sed -i "s/myserver.mydomain/localhost/g" /etc/awstats/awstats.dachs.conf \ | ||
78 | + ;else \ | ||
79 | + sed -i "s/mydomain/${DOMAIN}/g" /etc/awstats/awstats.dachs.conf && sed -i "s/myserver/${SERVERNAME}/g" /etc/awstats/awstats.dachs.conf \ | ||
80 | + ;fi | ||
81 | + | ||
82 | +##Adapt gavo.rc with ports and server name | ||
83 | + | ||
84 | +RUN sed -i "/serverPort/c\serverPort:${DACHS_PORT}" /etc/gavo.rc | ||
85 | +RUN sed -i "/corsOriginPat/c\corsOriginPat:${PROTOCOL}.*" /etc/gavo.rc | ||
86 | + | ||
87 | +RUN if [ "$SERVERNAME" = "localhost" ]; then \ | ||
88 | + sed -i "/serverURL/c\serverURL:" /etc/gavo.rc &&\ | ||
89 | + echo "############################ WARNING gavo.rc overwrite -- localhost for dev only ###############################" \ | ||
90 | + ; else \ | ||
91 | + sed -i "/serverURL/c\serverURL:${PROTOCOL}://${SERVERNAME}.${DOMAIN}:${DACHS_PORT}" /etc/gavo.rc &&\ | ||
92 | + echo "Warning : gavo.rc overwritten by .env servername, domain, protocol and port values" \ | ||
93 | + ; fi | ||
71 | 94 | ||
72 | ### | 95 | ### |
73 | #dachs configuration | 96 | #dachs configuration |
74 | ### | 97 | ### |
75 | - | ||
76 | RUN chown dachsroot:gavo /var/gavo/etc/defaultmeta.txt | 98 | RUN chown dachsroot:gavo /var/gavo/etc/defaultmeta.txt |
77 | RUN chown dachsroot:gavo /var/gavo/web/nv_static/img/logo* | 99 | RUN chown dachsroot:gavo /var/gavo/web/nv_static/img/logo* |
78 | RUN chown -R dachsroot:gavo /var/gavo/inputs/* | 100 | RUN chown -R dachsroot:gavo /var/gavo/inputs/* |
101 | +RUN chown -R dachsroot:gavo /var/gavo/logs | ||
79 | 102 | ||
80 | 103 | ||
81 | ### | 104 | ### |
@@ -88,9 +111,9 @@ RUN a2enmod cgi | @@ -88,9 +111,9 @@ RUN a2enmod cgi | ||
88 | ### | 111 | ### |
89 | # auto update awstats data using cron | 112 | # auto update awstats data using cron |
90 | ### | 113 | ### |
91 | - | 114 | +RUN mkdir -p ${HOMEPATH}/dachslogs |
92 | RUN echo "#!/bin/bash" > /etc/cron.daily/awstats | 115 | RUN echo "#!/bin/bash" > /etc/cron.daily/awstats |
93 | -RUN echo "/usr/bin/perl /usr/lib/cgi-bin/awstats.pl -config=dachs -update" >> /etc/cron.daily/awstats | 116 | +RUN echo "/usr/bin/perl /usr/lib/cgi-bin/awstats.pl -config=dachs -update" >> /etc/cron.daily/awstats |
94 | RUN chgrp 755 /etc/cron.daily/awstats | 117 | RUN chgrp 755 /etc/cron.daily/awstats |
95 | 118 | ||
96 | 119 |
docker-compose.yml renamed to conf/docker-compose.yml
@@ -19,15 +19,20 @@ services: | @@ -19,15 +19,20 @@ services: | ||
19 | dockerfile: dachs-dockerfile | 19 | dockerfile: dachs-dockerfile |
20 | args: | 20 | args: |
21 | - "VERSION=${VERSION}" | 21 | - "VERSION=${VERSION}" |
22 | + - "GITREPO_SERVER=${GITREPO_SERVER}" | ||
22 | - "GITREPO_INSTITUTION=${GITREPO_INSTITUTION}" | 23 | - "GITREPO_INSTITUTION=${GITREPO_INSTITUTION}" |
23 | - - "GITREPO_SERVER=${GITREPO_SERVER}" | ||
24 | - "DACHS_PORT=${DACHS_PORT}" | 24 | - "DACHS_PORT=${DACHS_PORT}" |
25 | - "APACHE_PORT=${APACHE_PORT}" | 25 | - "APACHE_PORT=${APACHE_PORT}" |
26 | - "SERVERNAME=${SERVERNAME}" | 26 | - "SERVERNAME=${SERVERNAME}" |
27 | - | ||
28 | -### example if you need to mount volumes (e.g if your service needs to parse files or if you want to upload it through dachs) | ||
29 | -# volumes: | ||
30 | -# - ./data:/home/dachsroot/data | ||
31 | - | 27 | + - "DOMAIN=${DOMAIN}" |
28 | + - "PROTOCOL=${PROTOCOL}" | ||
29 | + volumes: | ||
30 | + #- ../apache/cgi-bin:/home/dachsroot/apache/cgi-bin | ||
31 | + - ../apache/logapache:/var/log/apache2 | ||
32 | + - ../apache/dachslogs:/var/gavo/logs | ||
33 | + | ||
34 | + # example if you need to mount volumes (e.g if your service needs to parse files or if you want to upload it through dachs) | ||
35 | + #- paht/to/data:/var/gavo/inputs/service/data | ||
36 | + | ||
32 | ### To uncomment for production : | 37 | ### To uncomment for production : |
33 | # restart: always | 38 | # restart: always |
docker-entrypoint.sh renamed to conf/docker-entrypoint.sh
@@ -4,6 +4,8 @@ | @@ -4,6 +4,8 @@ | ||
4 | service ssh restart | 4 | service ssh restart |
5 | service postgresql restart | 5 | service postgresql restart |
6 | 6 | ||
7 | +/usr/bin/perl /usr/lib/cgi-bin/awstats.pl -config=dachs -update | ||
8 | + | ||
7 | for rep in $(find /var/gavo/inputs/[0-9a-zA-Z]* -maxdepth 0 -type d | cut -f5 -d'/') | 9 | for rep in $(find /var/gavo/inputs/[0-9a-zA-Z]* -maxdepth 0 -type d | cut -f5 -d'/') |
8 | do | 10 | do |
9 | su - dachsroot bash -c "dachs imp ${rep}/q.rd" | 11 | su - dachsroot bash -c "dachs imp ${rep}/q.rd" |
@@ -11,10 +13,10 @@ do | @@ -11,10 +13,10 @@ do | ||
11 | su - dachsroot bash -c "dachs pub //tap" | 13 | su - dachsroot bash -c "dachs pub //tap" |
12 | su - dachsroot bash -c "dachs pub ${rep}/q.rd" | 14 | su - dachsroot bash -c "dachs pub ${rep}/q.rd" |
13 | done | 15 | done |
14 | -dachs serve restart | ||
15 | - | 16 | +service dachs restart |
16 | service apache2 restart | 17 | service apache2 restart |
17 | 18 | ||
19 | + | ||
18 | #block a tester pour l'accès aux depots privé | 20 | #block a tester pour l'accès aux depots privé |
19 | #fonctionne avec la clé privé ssh (secrets dans docker compose) | 21 | #fonctionne avec la clé privé ssh (secrets dans docker compose) |
20 | eval "$(ssh-agent -s)" | 22 | eval "$(ssh-agent -s)" |
logos/logo_big.png renamed to conf/logos/logo_big.png
15.5 KB
logos/logo_medium.png renamed to conf/logos/logo_medium.png
9.49 KB
myconf.conf deleted
ports.conf deleted
@@ -1,16 +0,0 @@ | @@ -1,16 +0,0 @@ | ||
1 | -# If you just change the port or add more ports here, you will likely also | ||
2 | -# have to change the VirtualHost statement in | ||
3 | -# /etc/apache2/sites-enabled/000-default.conf | ||
4 | - | ||
5 | -Listen 8080 | ||
6 | - | ||
7 | -<IfModule ssl_module> | ||
8 | - Listen 443 | ||
9 | -</IfModule> | ||
10 | - | ||
11 | -<IfModule mod_gnutls.c> | ||
12 | - Listen 443 | ||
13 | -</IfModule> | ||
14 | - | ||
15 | -# vim: syntax=apache ts=4 sw=4 sts=4 sr noet | ||
16 | - |