forked from dankert/openrat-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
99 lines (87 loc) · 3.03 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
FROM alpine:3.10
LABEL maintainer="Jan Dankert"
# Install packages
RUN apk --update --no-cache add \
apache2 apache2-http2 \
php7 php7-apache2 php7-session php7-pdo php7-pdo_mysql php7-pdo_pgsql php7-json php7-ftp php7-iconv php7-openssl php7-mbstring \
git curl
ENV DB_TYPE="mysql" \
DB_HOST="localhost" \
DB_NAME="cms" \
DB_USER="cms" \
DB_PASS="" \
CMS_MOTD="Welcome to dockerized CMS" \
CMS_NAME="OpenRat CMS (Docker)" \
CMS_OPERATOR="Docker-Host" \
DOCROOT="/var/www/localhost/htdocs"
# Configuring apache webserver
RUN sed -i '/CustomLog/s/^/#/g' /etc/apache2/httpd.conf && \
sed -i '/LoadModule http2_module/s/^#//g' /etc/apache2/httpd.conf && \
sed -i 's/^Listen 80/Listen 8080/g' /etc/apache2/httpd.conf && \
chown apache /var/log/apache2 && \
chown apache /run/apache2 && \
rm -r $DOCROOT/* && \
mkdir -p /var/www/localhost/preview && \
chown apache /var/www/localhost/preview && \
echo "Alias /preview /var/www/localhost/preview" >> /etc/apache2/httpd.conf && \
echo "<Directory \"/var/www/localhost/preview\"> " >> /etc/apache2/httpd.conf && \
echo " AllowOverride None" >> /etc/apache2/httpd.conf && \
echo " Options None" >> /etc/apache2/httpd.conf && \
echo " Require all granted" >> /etc/apache2/httpd.conf && \
echo "</Directory>" >> /etc/apache2/httpd.conf && \
echo "Protocols h2 h2c http/1.1" >> /etc/apache2/httpd.conf && \
echo "H2ModernTLSOnly off" >> /etc/apache2/httpd.conf
# Copy the application to document root
COPY . $DOCROOT
# Place configuration in /etc, outside the docroot.
RUN echo "include: /etc/openrat.yml" > $DOCROOT/config/config.yml
# Create configuration
RUN echo -e '\
# OpenRat CMS configuration for Docker\n\
login:\n\
motd: "${env:CMS_MOTD}"\n\
\n\
database-default:\n\
default-id: db\n\
\n\
\n\
database:\n\
db:\n\
enabled : true\n\
dsn : "${env:DB_TYPE}:host=${env:DB_HOST}; dbname=${env:DB_NAME}"\n\
description: "PDO"\n\
name : "PRO"\n\
type : pdo\n\
user : ${env:DB_USER}\n\
password : ${env:DB_PASS}\n\
base64 : true # store binary as BASE64 (should be true for postgresql)\n\
prefix : cms_\n\
suffix : _or\n\
persistent : yes # use persistent connections (faster)\n\
charset : UTF-8\n\
cmd : ""\n\
prepare : true\n\
transaction: true\n\
\n\
log:\n\
file : "log/cms.log"\n\
level : "info"\n\
\n\
production: true\n\
\n\
publish:\n\
filesystem:\n\
directory: /var/www/localhost/preview\n\
\n\
application:\n\
name: "${env:CMS_NAME}"\n\
operator: "${env:CMS_OPERATOR}"\n\
\n\
' >> /etc/openrat.yml
# Logfiles are redirected to standard out
RUN ln -sf /dev/stdout $DOCROOT/log/cms.log && \
ln -sf /dev/stderr /var/log/apache2/error.log
EXPOSE 8080
WORKDIR $DOCROOT
USER apache
CMD /usr/sbin/httpd -D FOREGROUND