forked from xibosignage/xibo-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.ci
178 lines (152 loc) · 4.47 KB
/
Dockerfile.ci
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# this is the dev container and doesn't contain CRON or composer
# it maps the PWD straight through
# Multi-stage build
# Stage 0
# Compile xsendfile apache module
FROM alpine:3.15 as sendfile
ADD docker/mod_xsendfile.c /mod_xsendfile.c
RUN apk update && apk upgrade && apk add \
gcc \
musl-dev \
apache2-dev \
apache2
RUN cd / && \
apxs -cia mod_xsendfile.c
# Stage 1
# Run composer
FROM composer:1.6 as composer
COPY ./composer.json /app
COPY ./composer.lock /app
RUN composer install --no-interaction
# Stage 2
# Run webpack
FROM node:12 AS webpack
WORKDIR /app
# Install webpack
RUN npm install webpack -g
# Copy package.json and the webpack config file
COPY webpack.config.js .
COPY package.json .
COPY package-lock.json .
# Install npm packages
RUN npm install --only=prod
# Copy ui folder
COPY ./ui ./ui
# Copy modules source folder
COPY ./modules/src ./modules/src
# Build webpack
RUN npm run build
# Stage 1
# Build the CMS container
FROM alpine:3.15
MAINTAINER Xibo Signage <[email protected]>
# Install apache, PHP, and supplimentary programs.
RUN apk update && apk upgrade && apk add tar \
bash \
curl \
php7 \
php7-apache2 \
php7-zmq \
php7-json \
php7-gd \
php7-mcrypt \
php7-dom \
php7-pdo \
php7-zip \
php7-pdo_mysql \
php7-gettext \
php7-soap \
php7-iconv \
php7-curl \
php7-session \
php7-sockets \
php7-ctype \
php7-fileinfo \
php7-xml \
php7-simplexml \
php7-xmlwriter \
php7-tokenizer \
php7-mbstring \
php7-memcached \
php7-pecl-mongodb \
php7-zlib \
mysql-client \
msmtp \
python2 \
apache2 \
ca-certificates \
tzdata \
openssl \
&& rm -rf /var/cache/apk/*
# Add all necessary config files in one layer
ADD docker/ /
# Adjust file permissions as appropriate
RUN chmod +x /entrypoint.sh /usr/local/bin/httpd-foreground /usr/local/bin/wait-for-command.sh \
/etc/periodic/15min/cms-db-backup && \
mkdir -p /run/apache2 && \
rm /etc/apache2/conf.d/info.conf && \
rm /etc/apache2/conf.d/userdir.conf && \
chmod 777 /tmp
# Add xsendfile Module
COPY --from=sendfile /usr/lib/apache2/mod_xsendfile.so /usr/lib/apache2/mod_xsendfile.so
# Update the PHP.ini file
RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php7/php.ini && \
sed -i "s/session.gc_probability = .*$/session.gc_probability = 1/" /etc/php7/php.ini && \
sed -i "s/session.gc_divisor = .*$/session.gc_divisor = 100/" /etc/php7/php.ini
# Capture the git commit for this build if we provide one
ARG GIT_COMMIT=ci
# Set some environment variables
ENV CMS_DEV_MODE=true \
INSTALL_TYPE=ci \
MYSQL_HOST=db \
MYSQL_PORT=3306 \
MYSQL_USER=root \
MYSQL_PASSWORD=root \
MYSQL_DATABASE=cms \
MYSQL_BACKUP_ENABLED=false \
MYSQL_ATTR_SSL_CA=none \
MYSQL_ATTR_SSL_VERIFY_SERVER_CERT=true \
CMS_SERVER_NAME=localhost \
CMS_ALIAS=none \
CMS_PHP_SESSION_GC_MAXLIFETIME=1440 \
CMS_PHP_POST_MAX_SIZE=2G \
CMS_PHP_UPLOAD_MAX_FILESIZE=2G \
CMS_PHP_MAX_EXECUTION_TIME=300 \
CMS_PHP_MEMORY_LIMIT=256M \
CMS_PHP_COOKIE_SECURE=Off \
CMS_PHP_COOKIE_HTTP_ONLY=On \
CMS_PHP_COOKIE_SAMESITE=Lax \
CMS_APACHE_START_SERVERS=2 \
CMS_APACHE_MIN_SPARE_SERVERS=5 \
CMS_APACHE_MAX_SPARE_SERVERS=10 \
CMS_APACHE_MAX_REQUEST_WORKERS=60 \
CMS_APACHE_MAX_CONNECTIONS_PER_CHILD=300 \
CMS_APACHE_TIMEOUT=30 \
CMS_APACHE_OPTIONS_INDEXES=false \
CMS_QUICK_CHART_URL=http://cms-quickchart:3400 \
CMS_APACHE_SERVER_TOKENS=OS \
CMS_USE_MEMCACHED=false \
MEMCACHED_HOST=memcached \
MEMCACHED_PORT=11211 \
CMS_USAGE_REPORT=false \
XTR_ENABLED=true \
GIT_COMMIT=$GIT_COMMIT
# Expose port 80
EXPOSE 80
# Map the source files into /var/www/cms
# Create library and cache, because they might not exist
# Create /var/www/backup so that we have somewhere for entrypoint to log errors.
RUN mkdir -p /var/www/cms && \
mkdir -p /var/www/cms/library/temp && \
mkdir -p /var/www/cms/cache && \
mkdir -p /var/www/backup
# Composer generated vendor files
COPY --from=composer /app /var/www/cms
# Copy dist built webpack app folder to web
COPY --from=webpack /app/web/dist /var/www/cms/web/dist
# Copy modules built webpack app folder to cms modules
COPY --from=webpack /app/modules /var/www/cms/modules
# All other files (.dockerignore excludes things we don't want)
COPY . /var/www/cms
# Run entry
CMD ["/entrypoint.sh"]