Commit de175623f96f9dfa6c4fe7b20fd2fdd0582ac563
1 parent
583c729a
Exists in
master
ajoute la conf docker avec une fausse clé privé!
Showing
5 changed files
with
255 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,111 @@ |
1 | +ARG VERSION | |
2 | +FROM debian:$VERSION | |
3 | + | |
4 | +ARG SERVER | |
5 | +ARG GITURL | |
6 | +ARG GIT | |
7 | +ARG HOMEPATH=/home/dachsroot | |
8 | + | |
9 | + | |
10 | +### | |
11 | +#install de la clé + depot Dachs | |
12 | +# ajout de postgres en amont sinon l'install de dachs plante | |
13 | +### | |
14 | + | |
15 | +RUN apt-get -y update | |
16 | +RUN apt-get -y upgrade | |
17 | +RUN apt-get install -y curl apt-utils | |
18 | + | |
19 | +RUN curl -o /etc/apt/trusted.gpg.d/gavo-archive.key.asc https://docs.g-vo.org/archive-key.asc | |
20 | +RUN echo "deb http://vo.ari.uni-heidelberg.de/debian release main" > /etc/apt/sources.list.d/dachs.list | |
21 | + | |
22 | + | |
23 | +### | |
24 | +# Configuration du serveur | |
25 | +### | |
26 | + | |
27 | +RUN apt-get -y update | |
28 | +RUN apt-get -y upgrade | |
29 | +RUN apt-get install -y postgresql postgresql-pgsphere postgresql-q3c | |
30 | +RUN service postgresql restart && apt-get install -y git gavodachs2-server wget awstats geoip-database libgeo-ipfree-perl | |
31 | +RUN apt-get install -y git openssh-server openssh-client apache2 w3m net-tools vim | |
32 | + | |
33 | + | |
34 | +### | |
35 | +# Ajout des clés ssh | |
36 | +# port utilisé par defaut 2222 | |
37 | +### | |
38 | + | |
39 | +RUN mkdir -p /root/.ssh | |
40 | +RUN echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCx1IuqhW3UJmKWc6ODuhXu58CSdHGavVJaTUILUsR3ig359wRQ7GEpwXdk5dcTNOS16xVVx8KP7SEqsOOGRQ14jy2z3rJLZ0tRKzceCk1nXrFgipJ8qU0sFDc+dvXgJ94XvHlZzgQDT/iLeIZ6lhDEHn6O+EdfNf1g32LqIFXEe4fqRsKsM4ssYcHigdh3cdVDU350ACNxRrVEzCRE9lcGcfouwjSNMeWZO5SnCIzl7sOGJroYmL/c17P1YPIE1HzW3FjNI98FxJR2K/TmcUWJYDc7wDalN6HXyquoFsew7Sn/BZH0aprdaTLO1F820MTUIzcF/oKvhMd/Ihz355srm//a4PGQE7RDPdvPSjOr9KSiM/PU0GiARARex1AYl/a4CY5HnKeIs/sJfOADFJTpDcF7TSqKYq51JN1itWNmVMv8zZ/rfHMiEHKiDxLXZsflmdKPynHLI/Wk+uQqLNyORQ5MWJwKRGOp5haoCKxUtHPU68woVO1uk4FawXI0yLp84iXO7RJrr5MMas+Cjzv/azWA/K1WXOjiiWIqAoOHAYKWS2embavVHgIpbK/0wn8q5BF18QBOlqlpkBICOLTXpBLB+tAjmw998nYMF5PKI8synjzHGytd79OtrphO+ADWrCQuWDSxqkzbisJUMn3m1a4Z5CaaX1kjIL0P4RlvLw== phamy" >> /root/.ssh/authorized_keys | |
41 | +RUN chmod 700 /root/.ssh | |
42 | +RUN chmod 600 /root/.ssh/authorized_keys | |
43 | + | |
44 | +RUN mkdir -p /home/dachsroot/.ssh | |
45 | +RUN echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCx1IuqhW3UJmKWc6ODuhXu58CSdHGavVJaTUILUsR3ig359wRQ7GEpwXdk5dcTNOS16xVVx8KP7SEqsOOGRQ14jy2z3rJLZ0tRKzceCk1nXrFgipJ8qU0sFDc+dvXgJ94XvHlZzgQDT/iLeIZ6lhDEHn6O+EdfNf1g32LqIFXEe4fqRsKsM4ssYcHigdh3cdVDU350ACNxRrVEzCRE9lcGcfouwjSNMeWZO5SnCIzl7sOGJroYmL/c17P1YPIE1HzW3FjNI98FxJR2K/TmcUWJYDc7wDalN6HXyquoFsew7Sn/BZH0aprdaTLO1F820MTUIzcF/oKvhMd/Ihz355srm//a4PGQE7RDPdvPSjOr9KSiM/PU0GiARARex1AYl/a4CY5HnKeIs/sJfOADFJTpDcF7TSqKYq51JN1itWNmVMv8zZ/rfHMiEHKiDxLXZsflmdKPynHLI/Wk+uQqLNyORQ5MWJwKRGOp5haoCKxUtHPU68woVO1uk4FawXI0yLp84iXO7RJrr5MMas+Cjzv/azWA/K1WXOjiiWIqAoOHAYKWS2embavVHgIpbK/0wn8q5BF18QBOlqlpkBICOLTXpBLB+tAjmw998nYMF5PKI8synjzHGytd79OtrphO+ADWrCQuWDSxqkzbisJUMn3m1a4Z5CaaX1kjIL0P4RlvLw== phamy" >> /home/dachsroot/.ssh/authorized_keys | |
46 | +RUN chmod 700 /home/dachsroot/.ssh | |
47 | +RUN chmod 600 /home/dachsroot/.ssh/authorized_keys | |
48 | +RUN chown dachsroot:gavo -R /home/dachsroot/.ssh | |
49 | + | |
50 | + | |
51 | +### | |
52 | +# Installation des sources | |
53 | +### | |
54 | + | |
55 | +RUN mkdir $PATH$SERVER -p | |
56 | +RUN git clone $GITURL/$GIT.git $HOMEPATH/$SERVER/$GIT | |
57 | + | |
58 | +#on déplace les fichiers | |
59 | +RUN cp $HOMEPATH/$SERVER/$GIT/conf/000-default.conf /etc/apache2/sites-enabled/000-default.conf | |
60 | +RUN cp $HOMEPATH/$SERVER/$GIT/conf/ports.conf /etc/apache2/ports.conf | |
61 | +RUN cp $HOMEPATH/$SERVER/$GIT/conf/awstats.dachs.conf /etc/awstats/awstats.dachs.conf | |
62 | +RUN cp $HOMEPATH/$SERVER/$GIT/conf/gavo.rc /etc/gavo.rc | |
63 | +RUN cp $HOMEPATH/$SERVER/$GIT/conf/docker-entrypoint.sh /usr/bin/docker-entrypoint.sh | |
64 | +RUN chmod +x /usr/bin/docker-entrypoint.sh | |
65 | +RUN cp $HOMEPATH/$SERVER/$GIT/conf/defaultmeta.txt /var/gavo/etc/defaultmeta.txt | |
66 | +RUN mkdir /var/gavo/web/nv_static/img/ -p | |
67 | +RUN cp $HOMEPATH/$SERVER/$GIT/conf/logo* /var/gavo/web/nv_static/img/ | |
68 | +RUN cp -r $HOMEPATH/$SERVER/$GIT/services/* /var/gavo/inputs/ | |
69 | + | |
70 | + | |
71 | +### | |
72 | +#configuration de dachs | |
73 | +### | |
74 | + | |
75 | +RUN chown dachsroot:gavo /var/gavo/etc/defaultmeta.txt | |
76 | +RUN chown dachsroot:gavo /var/gavo/web/nv_static/img/logo* | |
77 | +RUN chown -R dachsroot:gavo /var/gavo/inputs/* | |
78 | + | |
79 | + | |
80 | +### | |
81 | +#configuration d'apache | |
82 | +### | |
83 | + | |
84 | +RUN a2enmod cgi | |
85 | + | |
86 | + | |
87 | +### | |
88 | +# maj auto des donnnées awstats par cron | |
89 | +### | |
90 | + | |
91 | +RUN echo "#!/bin/bash" > /etc/cron.daily/awstats | |
92 | +RUN echo "/usr/bin/perl /usr/lib/cgi-bin/awstats.pl -config=dachs -update" >> /etc/cron.daily/awstats | |
93 | +RUN chgrp 755 /etc/cron.daily/awstats | |
94 | + | |
95 | + | |
96 | +### | |
97 | +# Script de démarrage des servcices | |
98 | +### | |
99 | + | |
100 | +RUN echo "cd $HOMEPATH/$SERVER/$GIT/" >> /usr/bin/docker-entrypoint.sh | |
101 | +RUN echo "git pull" >> /usr/bin/docker-entrypoint.sh | |
102 | +# ajout au script pour maintenir docker up | |
103 | +#RUN echo "tail -f /dev/null" >> /usr/bin/docker-entrypoint.sh | |
104 | + | |
105 | + | |
106 | +ENTRYPOINT /usr/bin/docker-entrypoint.sh && tail -f /dev/null | |
107 | + | |
108 | +#ajout de clé ssh notamment pour les depots git--> clé privé danger | |
109 | +#vérifier les sub | |
110 | +#permettre l'acces ssh au moins au docker (hyperviseur aussi ?) | |
111 | +#faire un script maj | ... | ... |
... | ... | @@ -0,0 +1,29 @@ |
1 | +version: "3.7" | |
2 | +services: | |
3 | + | |
4 | + dachs: | |
5 | + container_name: dachs-voparis | |
6 | + image: dachs-voparis | |
7 | + tty: true | |
8 | + expose: | |
9 | + - "80" | |
10 | + - "8080" | |
11 | + - "22" | |
12 | + ports: | |
13 | + - "2222:22" | |
14 | + - "80:80" | |
15 | + - "8080:8080" | |
16 | + build: | |
17 | + context: . | |
18 | + dockerfile: dachs-dockerfile | |
19 | + args: | |
20 | + - "VERSION=${VERSION}" | |
21 | + - "SERVER=${SERVER}" | |
22 | + - "GITURL=${GITURL}" | |
23 | + - "GIT=${GIT}" | |
24 | + secrets: | |
25 | + - source: id_rsa | |
26 | + | |
27 | +secrets: | |
28 | + id_rsa: | |
29 | + file: id_rsa-phamy.prive | ... | ... |
... | ... | @@ -0,0 +1,108 @@ |
1 | +#source | |
2 | +https://docs.docker.com/compose/compose-file/ | |
3 | + | |
4 | +# commande nettoyage pour test | |
5 | +docker stop dachs-voparis && docker rm dachs-voparis && docker image rm dachs-voparis:latest && docker system prune | |
6 | + | |
7 | +#fonctionnement du docker | |
8 | +dans l'ordre | |
9 | +.env => définis les variables utilisé dans docker-compose.yml | |
10 | +docker-compose.yml => définis les dockers et les params de build des bulles | |
11 | +dachs-dockerfile => définis les lignes de commandes pour build dachs | |
12 | +docker-entrypoint.sh => script executé au démarrage du docker | |
13 | +secrets / id_rsa-phamy.prive ==> Ne JAMAIS mettre dans un git !!! | |
14 | + | |
15 | +docker-compose up -d ==> lance la séquence, --build pour forcer la maj | |
16 | + | |
17 | +docker image list => list les images | |
18 | +docker ps -a => list les dockers | |
19 | +docker image rm rep_dachs pour supprimer l'image docker | |
20 | +docker rm dachs pour supprimer le docker | |
21 | + | |
22 | +# link de docker | |
23 | +si besoin de séparer awstat | |
24 | +Ne pas utiliser link "depreciate" | |
25 | + | |
26 | +version: "3" | |
27 | +services: | |
28 | + | |
29 | + proxy: | |
30 | + build: ./proxy | |
31 | + networks: | |
32 | + - frontend | |
33 | + app: | |
34 | + build: ./app | |
35 | + networks: | |
36 | + - frontend | |
37 | + - backend | |
38 | + db: | |
39 | + image: postgres | |
40 | + networks: | |
41 | + - backend | |
42 | + | |
43 | +networks: | |
44 | + frontend: | |
45 | + # Use a custom driver | |
46 | + driver: custom-driver-1 | |
47 | + backend: | |
48 | + # Use a custom driver which takes special options | |
49 | + driver: custom-driver-2 | |
50 | + driver_opts: | |
51 | + foo: "1" | |
52 | + bar: "2" | |
53 | + | |
54 | +# volume data | |
55 | +ajouter dans le yaml docker-compose | |
56 | +version: "3" | |
57 | +services: | |
58 | + | |
59 | + db: | |
60 | + image: postgres:9.4 | |
61 | + volumes: | |
62 | + - db-data:/var/lib/postgresql/data | |
63 | + networks: | |
64 | + - backend | |
65 | + | |
66 | +networks: | |
67 | + frontend: | |
68 | + | |
69 | +volumes: | |
70 | + db-data: | |
71 | + | |
72 | +# passage de variable dans un docker-compose | |
73 | +Beside your docker-compose.yml file, create a new text file called .env. In it, add the following: | |
74 | +cat .env | |
75 | +CLIENT_ID=yourclientid | |
76 | +CLIENT_SECRET=yourclientsecret | |
77 | + | |
78 | +Now, open your docker-compose.yml file again, and replace yourclientid with ${CLIENT_ID} and yourclientsecret with ${CLIENT_SECRET}. That is: | |
79 | + | |
80 | +services: | |
81 | + app: | |
82 | + . . . #snipped | |
83 | + environment: | |
84 | + - GITHUB_CLIENT_ID=${CLIENT_ID} | |
85 | + - GITHUB_CLIENT_SECRET=${CLIENT_SECRET} | |
86 | + | |
87 | +# comment passer des mots des passes | |
88 | +version: "3.7" | |
89 | +services: | |
90 | + | |
91 | + dachs: | |
92 | + container_name: dachs-voparis | |
93 | + image: dachs-voparis | |
94 | + build: | |
95 | + dockerfile: dachs-dockerfile | |
96 | + secrets: | |
97 | + - id_rsa | |
98 | + | |
99 | +secrets: | |
100 | + id_rsa: | |
101 | + file: id_rsa-phamy.prive | |
102 | + | |
103 | +pour chaque docker dont le secrets id_rsa sera défini, le fichier sera copie dans le docker dans /run/secrets/id_rsa | |
104 | +root@c459f2b03173:~# ls -tralh /run/secrets/ | |
105 | +total 16K | |
106 | +-rw-r--r-- 1 dachsroot gavo 739 Nov 24 08:43 id_rsa | |
107 | +--> sans docker swarm les droits sont ceux de l'hote ! | |
108 | + | ... | ... |
No preview for this file type