forked from mmmaly/chcemvediet
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
163 lines (154 loc) · 4.51 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
155
156
157
158
159
160
161
162
163
FROM ubuntu:18.04
RUN \
apt-get update && \
apt-get install -y \
# Base system
gcc \
g++ \
gettext \
libssl-dev \
cron \
git \
vim \
# Dependencies
apache2 \
mysql-server \
python \
python-virtualenv \
python-dev \
libmysqlclient-dev \
libapache2-mod-wsgi \
libreoffice \
imagemagick \
libmagic1 \
webp \
&& \
:
# Setup user
RUN \
addgroup --gid 1001 chcemvediet && \
adduser --uid 1001 --gid 1001 --gecos '' --disabled-password chcemvediet && \
:
# Setup cron
RUN \
echo "* * * * * chcemvediet cd /home/chcemvediet/chcemvediet && env/bin/python manage.py runcrons" > /etc/cron.d/chcemvediet && \
:
# Setup mysql
RUN \
/etc/init.d/mysql start && \
printf "%s\n" \
"create database chcemvediet;" \
"alter database chcemvediet character set utf8mb4 collate utf8mb4_general_ci;" \
"grant all privileges on chcemvediet.* to chcemvediet@localhost identified by 'nbusr123';" \
| mysql && \
:
# Setup apache
RUN \
a2enmod ssl && \
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /root/chcemvediet.key -out /root/chcemvediet.crt -subj '/' && \
printf "%s\n" \
"<VirtualHost *:80>" \
" ServerName chcemvediet.local" \
" ServerAlias www.chcemvediet.local" \
" Redirect permanent / https://www.chcemvediet.local/" \
"</VirtualHost>" \
"" \
"<VirtualHost *:443>" \
" ServerName chcemvediet.local" \
" ServerAlias www.chcemvediet.local" \
"" \
" SSLEngine on" \
" SSLCertificateFile /root/chcemvediet.crt" \
" SSLCertificateKeyFile /root/chcemvediet.key" \
"" \
" Alias /robots.txt /home/chcemvediet/chcemvediet/static/robots.txt" \
" Alias /favicon.ico /home/chcemvediet/chcemvediet/static/favicon.ico" \
" Alias /static/ /home/chcemvediet/chcemvediet/static/" \
" <Directory /home/chcemvediet/chcemvediet/static>" \
" Require all granted" \
" Options -Indexes" \
" </Directory>" \
"" \
" WSGIScriptAlias / /home/chcemvediet/chcemvediet/chcemvediet/wsgi.py" \
" WSGIDaemonProcess chcemvediet user=chcemvediet group=chcemvediet python-path=/home/chcemvediet/chcemvediet:/home/chcemvediet/chcemvediet/env/lib/python2.7/site-packages" \
" WSGIProcessGroup chcemvediet" \
" <Directory /home/chcemvediet/chcemvediet/chcemvediet>" \
" <Files wsgi.py>" \
" Require all granted" \
" </Files>" \
" </Directory>" \
"</VirtualHost>" \
> /etc/apache2/sites-available/001-chcemvediet.conf && \
ln -s ../sites-available/001-chcemvediet.conf /etc/apache2/sites-enabled/001-chcemvediet.conf && \
:
# Setup imagemagick
RUN \
sed -i 's~<policy domain="coder" rights="none" pattern="PDF" />~<policy domain="coder" rights="read|write" pattern="PDF" />~' /etc/ImageMagick-6/policy.xml && \
:
# Clone repo
RUN \
cd /home/chcemvediet && \
su chcemvediet -c "git clone https://github.com/martinmacko47/chcemvediet.git" && \
:
# Run setup
RUN \
/etc/init.d/mysql start && \
cd /home/chcemvediet/chcemvediet && \
printf "%s\n" \
# Server mode: Production mode with no email infrastructure.
"6" \
# Mock libreoffice?
"n" \
# Mock imagemagic?
"n" \
# Mock abbyyocr11?
"y" \
# Install requirements for unittesting?
"n" \
# Server domain
"www.chcemvediet.local" \
# Admin e-mail (default)
"" \
# Support e-mail (default)
"" \
# Inforequest unique e-mail (default)
"" \
# Default from e-mail (default)
"" \
# Database name
"chcemvediet" \
# Database user name
"chcemvediet" \
# Database user password
"nbusr123" \
# Unique cache key prefix (default)
"" \
# Google Custom Search API key (default)
"" \
# Google reCaptcha public key (default)
"" \
# Google reCaptcha private key (default)
"" \
# Load datasheets / Neighbourhood dummy was omitted / Delete it?
"y" \
# Load datasheets / Municipality dummy was omitted / Delete it?
"y" \
# Load datasheets / District dummy was omitted / Delete it?
"y" \
# Load datasheets / Region dummy was omitted / Delete it?
"y" \
# Admin password
"nbusr123" \
# Google OAuth Client ID (default)
"" \
# Google OAuth Secret (default)
"" \
| su chcemvediet -c "PYTHONUNBUFFERED=1 python setup.py" && \
su chcemvediet -c "env/bin/python manage.py collectstatic --noinput" && \
:
EXPOSE 80 443
CMD \
/etc/init.d/mysql start && \
/etc/init.d/apache2 start && \
/etc/init.d/cron start && \
bash