dachs-dockerfile 3.5 KB
ARG VERSION
FROM debian:$VERSION

ARG GITURL
ARG SERVER
ARG INSTITUTION

ARG HOMEPATH=/home/dachsroot
ARG PUBKEY


###
#install de la clé + depot Dachs
# ajout de postgres en amont sinon l'install de dachs plante
###

RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get install -y curl apt-utils

# add dachs source
RUN curl -o /etc/apt/trusted.gpg.d/gavo-archive.key.asc https://docs.g-vo.org/archive-key.asc
RUN echo "deb http://vo.ari.uni-heidelberg.de/debian release main" > /etc/apt/sources.list.d/dachs.list


###
# Configuration du serveur
###

RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get install -y postgresql-13 postgresql-13-q3c postgresql-13-pgsphere 
RUN apt-get install -y git wget awstats net-tools vim
RUN service postgresql restart && apt-get install -y gavodachs2-server
RUN apt-get install -y openssh-server openssh-client apache2 w3m 


###
# Ajout des clés ssh
# port utilisé par defaut 2222
###

RUN mkdir -p /root/.ssh
RUN echo PUBKEY >> /root/.ssh/authorized_keys
RUN chmod 700 /root/.ssh
RUN chmod 600 /root/.ssh/authorized_keys

RUN mkdir -p /home/dachsroot/.ssh
RUN echo PUBKEY >> /home/dachsroot/.ssh/authorized_keys
RUN chmod 700 /home/dachsroot/.ssh
RUN chmod 600 /home/dachsroot/.ssh/authorized_keys
RUN chown dachsroot:gavo -R /home/dachsroot/.ssh


###
# Installation des sources
###

#copy the configuration files into the docker
COPY . $HOMEPATH


#import dachs server configuration files from git
RUN echo $GITURL/vespa/dachs/servers/$INSTITUTION/$SERVER.git
RUN git clone $GITURL/vespa/dachs/servers/$INSTITUTION/$SERVER.git $HOMEPATH/server



#on déplace les fichiers
# dachs server configuration
RUN cp $HOMEPATH/000-default.conf /etc/apache2/sites-enabled/000-default.conf
RUN cp $HOMEPATH/ports.conf /etc/apache2/ports.conf
RUN cp $HOMEPATH/awstats.dachs.conf /etc/awstats/awstats.dachs.conf
RUN cp $HOMEPATH/server/gavo.rc /etc/gavo.rc
RUN cp $HOMEPATH/docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
RUN chmod +x /usr/bin/docker-entrypoint.sh
RUN cp $HOMEPATH/server/defaultmeta.txt /var/gavo/etc/defaultmeta.txt
RUN mkdir /var/gavo/web/nv_static/img/ -p
RUN cp $HOMEPATH/logo* /var/gavo/web/nv_static/img/


#import services from git
#clone all repositories from the group -- only if the gitlab project is Public
RUN wget -O $HOMEPATH/group.json $GITURL'/api/v4/groups/vespa%2Fdachs%2Fservices%2F'$INSTITUTION'%2F'$SERVER
RUN mkdir $HOMEPATH/services/ && cd $HOMEPATH/services/ && egrep -o 'https://[^"]+\.git' $HOMEPATH/group.json|xargs -n 1 -P 8 git clone
RUN cp -r $HOMEPATH/services/* /var/gavo/inputs/

###
#configuration de dachs
###

RUN chown dachsroot:gavo /var/gavo/etc/defaultmeta.txt
RUN chown dachsroot:gavo /var/gavo/web/nv_static/img/logo*
RUN chown -R dachsroot:gavo /var/gavo/inputs/*


###
#configuration d'apache
###

RUN a2enmod cgi


###
# maj auto des donnnées awstats par cron
###

RUN echo "#!/bin/bash" > /etc/cron.daily/awstats
RUN echo "/usr/bin/perl /usr/lib/cgi-bin/awstats.pl -config=dachs -update" >> /etc/cron.daily/awstats
RUN chgrp 755 /etc/cron.daily/awstats


###
# Script de démarrage des services
###

RUN echo "cd $HOMEPATH/$SERVER/$GIT/" >> /usr/bin/docker-entrypoint.sh
RUN echo "git pull" >> /usr/bin/docker-entrypoint.sh

# ajout au script pour maintenir docker up
RUN echo "tail -f /dev/null" >> /usr/bin/docker-entrypoint.sh


ENTRYPOINT /usr/bin/docker-entrypoint.sh && tail -f /dev/null

#ajout de clé ssh notamment pour les depots git--> clé privé danger
#vérifier les sub
#permettre l'acces ssh au moins au docker (hyperviseur aussi ?)
#faire un script maj