-
Notifications
You must be signed in to change notification settings - Fork 55
/
Dockerfile.template
90 lines (76 loc) · 4.06 KB
/
Dockerfile.template
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
FROM php:%%PHP_VERSION%%-%%VARIANT%%
RUN apt-get update && apt-get install -y cron git-core jq unzip vim zip \
libjpeg-dev libpng-dev libpq-dev libsqlite3-dev libwebp-dev libzip-dev && \
rm -rf /var/lib/apt/lists/* && \
%%PHP_ZIP_CONFIG%% && \
%%PHP_GD_CONFIG%% && \
docker-php-ext-install exif gd mysqli opcache pdo_pgsql pdo_mysql zip
# Recommended opcache settings - https://secure.php.net/manual/en/opcache.installation.php
RUN { \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=2'; \
echo 'opcache.fast_shutdown=1'; \
echo 'opcache.enable_cli=1'; \
} > /usr/local/etc/php/conf.d/docker-oc-opcache.ini
RUN { \
echo 'log_errors=on'; \
echo 'display_errors=off'; \
echo 'upload_max_filesize=32M'; \
echo 'post_max_size=32M'; \
echo 'memory_limit=128M'; \
} > /usr/local/etc/php/conf.d/docker-oc-php.ini
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \
/usr/local/bin/composer global require hirak/prestissimo
%%VARIANT_EXTRAS%%
COPY config/docker /usr/src/octobercms-config-docker
ENV OCTOBERCMS_TAG %%OCTOBERCMS_TAG%%
ENV OCTOBERCMS_CHECKSUM %%OCTOBERCMS_CHECKSUM%%
ENV OCTOBERCMS_CORE_BUILD %%OCTOBERCMS_CORE_BUILD%%
ENV OCTOBERCMS_CORE_HASH %%OCTOBERCMS_CORE_HASH%%
# Consolidated October CMS setup
RUN git clone https://github.com/octobercms/october.git -b $OCTOBERCMS_TAG --depth 1 . && \
# match build dependencies
echo "Update composer.json: Set explicit build references for october module dependencies" && \
sed -i.orig "s/\(\"october\/\([rain|system|backend|cms]*\)\": \"\(~1.0\)\"\)/\"october\/\2\": \"<=${OCTOBERCMS_TAG#v}\"/g" composer.json && \
egrep -o "['\"]october\/[rain|system|backend|cms]*['\"]\s*:\s*['\"](.+?)['\"]" composer.json && \
# download dependencies
composer install --no-interaction --prefer-dist --no-scripts && \
composer clearcache && \
# ensure modules are in sync with the repo after composer install
git status && git checkout modules/. && \
# remove git repo
rm -rf .git && \
# setup docker env
echo 'APP_ENV=docker' > .env && \
mv /usr/src/octobercms-config-docker config/docker && \
# setup database
touch storage/database.sqlite && \
chmod 666 storage/database.sqlite && \
php artisan october:up && \
# add October Drivers
php artisan plugin:install october.drivers && \
# permissions
chown -R www-data:www-data /var/www/html && \
find . -type d \( -path './plugins' -or -path './storage' -or -path './themes' -or -path './plugins/*' -or -path './storage/*' -or -path './themes/*' \) -exec chmod g+ws {} \;
# Set October build params
RUN php -r "use System\\Models\\Parameter; \
require __DIR__.'/bootstrap/autoload.php'; \
\$app = require_once __DIR__.'/bootstrap/app.php'; \
\$app->make('Illuminate\\Contracts\\Console\\Kernel')->bootstrap(); \
Parameter::set(['system::core.build'=>getenv('OCTOBERCMS_CORE_BUILD'), 'system::core.hash'=>getenv('OCTOBERCMS_CORE_HASH')]); \
echo \"October CMS \\n Build: \",Parameter::get('system::core.build'), \"\\n Hash: \", Parameter::get('system::core.hash'), \"\\n\";"
# Initialize crontab for the October CMS scheduler
RUN echo "* * * * * /usr/local/bin/php /var/www/html/artisan schedule:run > /proc/1/fd/1 2>/proc/1/fd/2" > /etc/cron.d/october-cron && \
crontab /etc/cron.d/october-cron
# Add helpers
RUN echo 'exec php artisan "$@"' > /usr/local/bin/artisan && \
echo 'exec php artisan tinker' > /usr/local/bin/tinker && \
echo '[ $# -eq 0 ] && exec php artisan october || exec php artisan october:"$@"' > /usr/local/bin/october && \
sed -i '1s;^;#!/bin/bash\n[ "$PWD" != "/var/www/html" ] \&\& echo " - Helper must be run from /var/www/html" \&\& exit 1\n;' /usr/local/bin/artisan /usr/local/bin/tinker /usr/local/bin/october && \
chmod +x /usr/local/bin/artisan /usr/local/bin/tinker /usr/local/bin/october
COPY docker-oc-entrypoint /usr/local/bin/
ENTRYPOINT ["docker-oc-entrypoint"]
CMD ["%%CMD%%"]