-
Notifications
You must be signed in to change notification settings - Fork 14
/
Dockerfile-gstudio
executable file
·146 lines (115 loc) · 9.45 KB
/
Dockerfile-gstudio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# set the base image to registry.tiss.edu/gstudiobase
FROM registry.tiss.edu/gstudiobase
ARG gstudio_docker_commit_no="077e1bc94963e7e8781c2400a5a482fdb670c925"
ARG gstudio_commit_no="8aee52ce41397958aa5244148693177a32d299de"
ARG qbank_lite_commit_no="21f0d25a95b3e2f641269696f591a9a007ac76ee"
ARG OpenAssessmentsClient_commit_no="41c9b1609dc8a84d53b533e7292fd0536a625c34"
ARG qbank_gstudio-scripts_commit_no="cc47ba90634e3f944be2c443b9088c7edde80f2a"
# file Author / Maintainer to Mrunal
MAINTAINER [email protected]
# create code directory as it can't find dirctory while coping
RUN mkdir -p /home/docker/code/ /data/db /data/rcs-repo /data/media /data/system-heartbeat /data/postgres-dump /softwares
# # install our code
# ADD . /home/docker/code/
# change the working directory to "/home/docker/code"
WORKDIR "/home/docker/code/"
# install qbank-gstudio-scripts code and pip install to install pip related required packages as per requirements.txt
RUN git clone https://[email protected]/CLIxIndia-Dev/qbank-gstudio-scripts.git \
&& cd qbank-gstudio-scripts && git reset --hard $qbank_gstudio_scripts_commit_no && cd .. \
&& pip install -r /home/docker/code/qbank-gstudio-scripts/single_school_get_MIT_activity_data/requirements.txt
# install gstudio docker code
RUN git clone https://[email protected]/mrunal4/gstudio-docker.git \
&& cd gstudio-docker && git reset --hard $gstudio_docker_commit_no && cd .. \
&& rsync -avPh --include="/*/" --include="*/.*" --include="*" gstudio-docker/ . \
&& rm -rf gstudio-docker
# install gstudio app code, reset code to given commit no, pip install to install pip related required packages as per requirements.txt, and bower install
RUN git clone -b master https://[email protected]/gnowledge/gstudio.git \
&& cd gstudio && git reset --hard $gstudio_commit_no && cd .. \
&& pip install -r /home/docker/code/gstudio/requirements.txt \
&& cd /home/docker/code/gstudio/gnowsys-ndf/ \
&& bower install --allow-root
# Clone dlkit repos at manage.py level
RUN cd /home/docker/code/gstudio/gnowsys-ndf/ \
&& git clone https://bitbucket.org/cjshaw/dlkit_runtime.git \
&& git clone https://bitbucket.org/cjshaw/dlkit.git \
&& cd dlkit \
&& git submodule update --init --recursive
# Clone qbank repos at manage.py level
RUN cd /home/docker/code/gstudio/gnowsys-ndf/ \
&& git clone -b clixserver.tiss.edu https://github.com/gnowledge/qbank-lite.git \
&& cd qbank-lite && git reset --hard $qbank_lite_commit_no && cd .. \
&& cd qbank-lite \
&& git submodule update --init --recursive
# Clone OpenAssessmentsClient repos at gstudio level
RUN cd /home/docker/code/ \
&& git clone -b clixserver.tiss.edu https://github.com/gnowledge/OpenAssessmentsClient.git \
&& mkdir -p /home/docker/code/gstudio/gnowsys-ndf/qbank-lite/webapps/CLIx/datastore/repository/AssetContent /home/docker/code/gstudio/gnowsys-ndf/qbank-lite/webapps/CLIx/datastore/studentResponseFiles \
&& cd OpenAssessmentsClient && git reset --hard $OpenAssessmentsClient_commit_no && cd .. \
&& cd OpenAssessmentsClient \
# && npm build \
&& yarn \
&& yarn build \
&& mkdir -p /softwares/oac /softwares/oat \
&& cp -av /home/docker/code/OpenAssessmentsClient/build/prod/* /softwares/oac/ \
&& cp -av /home/docker/code/OpenAssessmentsClient/build/prod/* /softwares/oat/ \
&& cp -av /softwares/oat/author.html /softwares/oat/index.html
# backup all scripts, confs and restore schema dump (restore factory dump)
RUN mkdir /root/.backup_defaults \
&& cp -av /home/docker/code/confs /home/docker/code/scripts /home/docker/code/Dockerfile /home/docker/code/AUTHORS /home/docker/code/README.md /root/.backup_defaults/ \
&& rm -rf /home/docker/code/schema_dump/data
# checking the present working directory and copying of configfiles : {copying the '.emacs' file in /root/ } , {copying the 'maintenance' files in /home/docker/code/gstudio/gnowsys-ndf/gnowsys_ndf/ndf/templates/ } , {copying wsgi file to appropriate location}, {copying postgresql conf file to appropriate location} ,
RUN pwd | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& cp -v /home/docker/code/confs/emacs /root/.emacs | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& cp -v /home/docker/code/maintenance/maintenance* /home/docker/code/gstudio/gnowsys-ndf/gnowsys_ndf/ndf/templates/ | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& cp -v /home/docker/code/gstudio/gnowsys-ndf/gnowsys_ndf/wsgi.py /home/docker/code/gstudio/gnowsys-ndf/wsgi.py | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& rm /etc/postgresql/9.3/main/postgresql.conf | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& cp -v /home/docker/code/confs/local_settings.py.default /home/docker/code/gstudio/gnowsys-ndf/gnowsys_ndf/local_settings.py \
&& cat /home/docker/code/confs/bash_compl >> /root/.bashrc | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER}
# setup all the configfiles (nginx, supervisord and postgresql)
RUN echo "daemon off;" >> /etc/nginx/nginx.conf \
&& rm /etc/nginx/sites-enabled/default | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& mv -v /etc/nginx/nginx.conf /tmp/ | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& ln -s /home/docker/code/confs/nginx.conf /etc/nginx/ | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& ln -s /home/docker/code/confs/nginx-app.conf /etc/nginx/sites-enabled/ | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& ln -s /home/docker/code/confs/supervisor-app.conf /etc/supervisor/conf.d/ | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& ln -s /home/docker/code/confs/postgresql.conf /etc/postgresql/9.3/main/ | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& mv -v /etc/mailname /tmp/ | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& ln -s /home/docker/code/confs/mailname /etc/mailname | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& mv -v /etc/postfix/main.cf /tmp/ | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& ln -s /home/docker/code/confs/main.cf /etc/postfix/ | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& ln -s /home/docker/code/confs/sasl_passwd /etc/postfix/ | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& ln -s /home/docker/code/confs/sasl_passwd.db /etc/postfix/ | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER}
# remove all deb packages
RUN echo "Size of deb packages files : " du -hs /var/cache/apt/archives/ \
&& ls -ltr /var/cache/apt/archives/ \
&& du -hs /var/cache/apt/archives/* \
&& rm -rf /var/cache/apt/archives/*.deb
# Set necessary permissions to mongodb data directory (/data/db)
RUN mkdir -p /data/db && chown -R mongodb:mongodb /data/db | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER}
# Set volumes
VOLUME /data
VOLUME /backups
VOLUME /softwares
VOLUME /home/docker/code/gstudio/gnowsys-ndf/qbank-lite/webapps/CLIx/datastore
# Exposing the ports - {ssh} , {smtp} , {https (with ssl)} , {http} , {for developement user (Developer)} , {smtpd command (to test mail machanism locally)} , {imap : gnowledge} , {smtp : gnowledge} , {mongodb}
RUN echo "EXPOSE 22 25 80 443 8000 8080 1025 143 587 27017 5555" | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER}
EXPOSE 22 25 80 443 8000 8080 1025 143 587 27017 5555
# {change this line for your timezone} and {nltk installation and building search base} and {creation of schema_files directory}
RUN ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& pip install -U pyyaml nltk | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& /home/docker/code/scripts/nltk-initialization.py | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER} \
&& mkdir /home/docker/code/gstudio/gnowsys-ndf/gnowsys_ndf/ndf/management/commands/schema_files | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER}
# Restore default postgres database
RUN /etc/init.d/postgresql start \
&& cd /home/docker/code/schema_dump/ \
&& tar xvjf schema-dump.tar \
&& rsync -avPh data/* /data/ \
&& echo "psql -f /data/pgdata.sql;" | sudo su - postgres \
&& crontab /home/docker/code/confs/mycron \
&& rm /etc/rc.local \
&& /etc/init.d/rc.local start \
&& ln -s /home/docker/code/confs/rc.local /etc/ \
&& /etc/init.d/postgresql start
# Perform collectstatic
RUN echo yes | /usr/bin/python /home/docker/code/gstudio/gnowsys-ndf/manage.py collectstatic
CMD /home/docker/code/scripts/initialize.sh | sed -e "s/^/$(date +%Y%m%d-%H%M%S) : /" 2>&1 | tee -a ${LOG_INSTALL_DOCKER}