forked from inveniosoftware/invenio
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
154 lines (142 loc) · 6.18 KB
/
Dockerfile
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
147
148
149
150
151
152
153
154
# This file is part of Invenio.
# Copyright (C) 2015 CERN.
#
# Invenio is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Invenio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Invenio; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
# Using CentOS-6 with Python-2.6 and MySQL-5.1, fitting our minimal
# requirements for Invenio v1.2:
FROM centos:6
# Installing OS prerequisites:
RUN yum update -y && \
yum install -y epel-release && \
yum install -y automake \
file \
freetype-devel \
gcc \
gcc-c++ \
gettext \
gettext-devel \
git \
hdf5-devel \
ipython \
libpng-devel \
libxslt-devel \
libreoffice \
libreoffice-headless \
libreoffice-pyuno \
mod_ssl \
mod_wsgi \
mysql-devel \
mysql-server \
poppler-utils \
python-devel \
python-magic \
python-pip \
redis \
sendmail \
sudo \
texlive \
unzip \
w3m \
wget && \
yum clean all
# Installing Python prerequisites:
ADD requirements.txt /tmp/requirements.txt
ADD requirements-extras.txt /tmp/requirements-extras.txt
RUN pip install --upgrade distribute && \
pip install supervisor && \
pip install -r /tmp/requirements.txt && \
pip install -r /tmp/requirements-extras.txt
# Run container as `apache` user, with forced UID of 1000, which
# should match current host user in most situations:
RUN usermod -u 1000 apache && \
echo "apache ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Creating Python symlink:
RUN mkdir -p /opt/invenio/lib/python/invenio && \
ln -s /opt/invenio/lib/python/invenio /usr/lib/python2.6/site-packages && \
ln -s /opt/invenio/lib/python/invenio /usr/lib64/python2.6/site-packages && \
chown -R apache.apache /opt/invenio && \
mkdir /.texmf-var && \
chown apache /.texmf-var
# Allowing sudo from non-tty connections:
RUN sed -i 's,Defaults requiretty,#Defaults requiretty,g' /etc/sudoers
# Creating DB:
RUN /sbin/service mysqld start && \
mysqladmin -u root password '' && \
echo "DROP DATABASE IF EXISTS invenio;" | mysql -u root -B && \
echo "CREATE DATABASE invenio DEFAULT CHARACTER SET utf8;" | mysql -u root -B && \
echo 'GRANT ALL PRIVILEGES ON invenio.* TO invenio@localhost IDENTIFIED BY "my123pass"' | mysql -u root -B
# Installing Supervisor:
RUN echo "[supervisord]" > /etc/supervisord.conf && \
echo "nodaemon=true" >> /etc/supervisord.conf && \
echo "" >> /etc/supervisord.conf && \
echo "[program:sendmail]" >> /etc/supervisord.conf && \
echo "command=/etc/init.d/sendmail start" >> /etc/supervisord.conf && \
echo "" >> /etc/supervisord.conf && \
echo "[program:redis-server]" >> /etc/supervisord.conf && \
echo "command=/usr/sbin/redis-server /etc/redis.conf" >> /etc/supervisord.conf && \
echo "" >> /etc/supervisord.conf && \
echo "[program:mysqld]" >> /etc/supervisord.conf && \
echo "command=/usr/bin/mysqld_safe" >> /etc/supervisord.conf && \
echo "autostart=true" >> /etc/supervisord.conf && \
echo "autorestart=true" >> /etc/supervisord.conf && \
echo "user=root" >> /etc/supervisord.conf && \
echo "" >> /etc/supervisord.conf && \
echo "[program:httpd]" >> /etc/supervisord.conf && \
echo "command=/usr/sbin/apachectl -D FOREGROUND" >> /etc/supervisord.conf
# Adding current directory as `/code`; assuming people have `master` branch checked out:
# (note: this invalidates cache, but most of hard yum install is done by now)
ADD . /code
WORKDIR /code
RUN chown -R apache /code
# Installing Invenio:
USER apache
RUN sudo /sbin/service mysqld restart && \
sudo /sbin/service redis restart && \
rm -rf autom4te.cache/ && \
aclocal && \
automake -a && \
autoconf && \
./configure && \
make -s clean && \
make -s && \
make -s install && \
make -s install-jquery-plugins && \
make -s install-mathjax-plugin && \
make -s install-ckeditor-plugin && \
make -s install-mediaelement && \
make -s install-pdfa-helper-files && \
mkdir -p /opt/invenio/var/tmp/ooffice-tmp-files && \
sudo chgrp -R nobody /opt/invenio/var/tmp/ooffice-tmp-files && \
sudo chmod -R 775 /opt/invenio/var/tmp/ooffice-tmp-files && \
echo "[Invenio]" > /opt/invenio/etc/invenio-local.conf && \
echo "CFG_SITE_URL = http://0.0.0.0" >> /opt/invenio/etc/invenio-local.conf && \
echo "CFG_SITE_SECURE_URL = https://0.0.0.0" >> /opt/invenio/etc/invenio-local.conf && \
echo "CFG_DATABASE_PASS = my123pass" >> /opt/invenio/etc/invenio-local.conf && \
chown -R apache /opt/invenio && \
/opt/invenio/bin/inveniocfg --update-all && \
/opt/invenio/bin/inveniocfg --create-tables --yes-i-know && \
/opt/invenio/bin/inveniocfg --load-bibfield-conf && \
/opt/invenio/bin/inveniocfg --create-apache-conf --yes-i-know && \
/opt/invenio/bin/inveniocfg --create-demo-site --yes-i-know && \
/opt/invenio/bin/inveniocfg --load-demo-records --yes-i-know
# Configuring Apache:
USER root
RUN sed -i 's,^Alias /error,#Alias /error,g' /etc/httpd/conf/httpd.conf && \
echo "Include /opt/invenio/etc/apache/invenio-apache-vhost.conf" >> /etc/httpd/conf/httpd.conf && \
echo "Include /opt/invenio/etc/apache/invenio-apache-vhost-ssl.conf" >> /etc/httpd/conf/httpd.conf
# Starting the application:
EXPOSE 80 443
USER apache
CMD ["sudo", "-u", "root", "/usr/bin/supervisord"]