2016-10-02 03:50:40 +05:30
|
|
|
|
FROM php:7.0-fpm
|
2016-05-02 13:31:38 +05:30
|
|
|
|
|
2016-05-10 04:19:50 +05:30
|
|
|
|
ENV PATH $PATH:/root/.composer/vendor/bin
|
2016-05-05 13:45:53 +05:30
|
|
|
|
|
2016-10-02 03:50:40 +05:30
|
|
|
|
# Сначала настраиваем всё, что нам нужно на системном уровне
|
2016-05-10 04:19:50 +05:30
|
|
|
|
RUN apt-get update \
|
|
|
|
|
&& apt-get -y install \
|
|
|
|
|
git \
|
|
|
|
|
g++ \
|
|
|
|
|
libicu-dev \
|
|
|
|
|
libmcrypt-dev \
|
|
|
|
|
zlib1g-dev \
|
2016-10-02 03:50:40 +05:30
|
|
|
|
bzip2 \
|
|
|
|
|
libbz2-dev \
|
|
|
|
|
liblzma-dev \
|
|
|
|
|
xz-utils \
|
2016-09-15 21:22:07 +05:30
|
|
|
|
openssh-server \
|
2016-10-02 03:50:40 +05:30
|
|
|
|
supervisor \
|
2016-05-10 04:19:50 +05:30
|
|
|
|
--no-install-recommends \
|
2016-10-02 03:50:40 +05:30
|
|
|
|
--force-yes \
|
2016-05-10 04:19:50 +05:30
|
|
|
|
|
2016-10-02 03:50:40 +05:30
|
|
|
|
# PHP расширения
|
2016-05-10 04:19:50 +05:30
|
|
|
|
&& docker-php-ext-install intl \
|
|
|
|
|
&& docker-php-ext-install pdo_mysql \
|
|
|
|
|
&& docker-php-ext-install mbstring \
|
|
|
|
|
&& docker-php-ext-install mcrypt \
|
|
|
|
|
&& docker-php-ext-install zip \
|
|
|
|
|
&& docker-php-ext-install bcmath \
|
2016-10-02 03:50:40 +05:30
|
|
|
|
&& docker-php-ext-install opcache \
|
2016-05-10 04:19:50 +05:30
|
|
|
|
|
|
|
|
|
&& apt-get purge -y g++ \
|
|
|
|
|
&& apt-get autoremove -y \
|
|
|
|
|
&& rm -r /var/lib/apt/lists/* \
|
|
|
|
|
|
2016-10-02 03:50:40 +05:30
|
|
|
|
# Отключаем сброс глобальных env переменных внутри PHP
|
2016-05-10 04:19:50 +05:30
|
|
|
|
&& echo "\nclear_env = no" >> /usr/local/etc/php-fpm.conf \
|
|
|
|
|
|
2016-10-02 03:50:40 +05:30
|
|
|
|
# Фикс прав на запись для расшаренных папок
|
2016-05-10 04:19:50 +05:30
|
|
|
|
&& usermod -u 1000 www-data
|
|
|
|
|
|
2016-10-02 03:50:40 +05:30
|
|
|
|
# Копипаста из https://github.com/nodejs/docker-node/blob/50b56d39a236fd519eda2231757aa2173e270807/5.12/Dockerfile
|
2016-09-09 19:36:25 +05:30
|
|
|
|
|
|
|
|
|
# gpg keys listed at https://github.com/nodejs/node
|
|
|
|
|
RUN set -ex \
|
2016-10-02 03:50:40 +05:30
|
|
|
|
&& for key in \
|
|
|
|
|
9554F04D7259F04124DE6B476D5A82AC7E37093B \
|
|
|
|
|
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
|
|
|
|
|
0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \
|
|
|
|
|
FD3A5288F042B6850C66B31F09FE44734EB7990E \
|
|
|
|
|
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
|
|
|
|
|
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
|
|
|
|
|
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
|
|
|
|
|
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
|
|
|
|
|
; do \
|
|
|
|
|
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
|
|
|
|
|
done
|
2016-09-09 19:36:25 +05:30
|
|
|
|
|
|
|
|
|
ENV NPM_CONFIG_LOGLEVEL info
|
2016-10-02 03:50:40 +05:30
|
|
|
|
ENV NODE_VERSION 5.12.0
|
2016-09-09 19:36:25 +05:30
|
|
|
|
|
|
|
|
|
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
|
|
|
|
|
&& curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
|
|
|
|
|
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
|
|
|
|
&& grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
|
|
|
|
|
&& tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 \
|
|
|
|
|
&& rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
|
|
|
|
|
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
|
|
|
|
|
|
2016-08-07 05:39:08 +05:30
|
|
|
|
ENV COMPOSER_NO_INTERACTION 1
|
2016-10-02 03:50:40 +05:30
|
|
|
|
ENV COMPOSER_ALLOW_SUPERUSER 1
|
|
|
|
|
ENV COMPOSER_DISCARD_CHANGES true
|
2016-08-07 05:39:08 +05:30
|
|
|
|
|
2016-10-02 03:50:40 +05:30
|
|
|
|
# Composer и его глобальные зависимости
|
2016-05-10 04:19:50 +05:30
|
|
|
|
RUN curl -sS https://getcomposer.org/installer | php \
|
|
|
|
|
&& mv composer.phar /usr/local/bin/composer.phar \
|
2016-06-16 13:30:16 +05:30
|
|
|
|
&& echo '{"github-oauth": {"github.com": "***REMOVED***"}}' > ~/.composer/auth.json \
|
2016-10-02 03:50:40 +05:30
|
|
|
|
&& composer.phar global require --no-progress "hirak/prestissimo:>=0.3.4"
|
2016-05-10 04:19:50 +05:30
|
|
|
|
|
|
|
|
|
COPY ./docker/php/composer.sh /usr/local/bin/composer
|
2016-10-02 03:50:40 +05:30
|
|
|
|
|
|
|
|
|
# Конфиг для php
|
|
|
|
|
COPY ./docker/php/php.ini /usr/local/etc/php/
|
|
|
|
|
|
|
|
|
|
# Конфиг для supervisor
|
|
|
|
|
COPY ./docker/php/supervisord.conf /etc/supervisord.conf
|
|
|
|
|
|
|
|
|
|
# wait-for-it
|
|
|
|
|
COPY ./docker/wait-for-it.sh /usr/local/bin/wait-for-it
|
|
|
|
|
|
|
|
|
|
# Наша кавайная точка входа
|
|
|
|
|
COPY ./docker/php/entrypoint.sh /usr/local/bin/
|
|
|
|
|
|
|
|
|
|
RUN chmod a+x /usr/local/bin/composer \
|
|
|
|
|
&& chmod a+x /usr/local/bin/entrypoint.sh \
|
|
|
|
|
&& chmod a+x /usr/local/bin/wait-for-it \
|
|
|
|
|
&& ln -s /usr/local/bin/entrypoint.sh / \
|
|
|
|
|
&& mkdir /root/.ssh
|
|
|
|
|
|
|
|
|
|
COPY id_rsa /root/.ssh
|
|
|
|
|
|
|
|
|
|
# Включаем поддержку ssh
|
|
|
|
|
RUN eval $(ssh-agent -s) \
|
|
|
|
|
&& ssh-add /root/.ssh/id_rsa \
|
|
|
|
|
&& touch /root/.ssh/known_hosts \
|
|
|
|
|
&& ssh-keyscan gitlab.com >> /root/.ssh/known_hosts
|
2016-05-10 04:19:50 +05:30
|
|
|
|
|
|
|
|
|
WORKDIR /var/www/html
|
2016-05-02 13:31:38 +05:30
|
|
|
|
|
2016-10-02 03:50:40 +05:30
|
|
|
|
# Копируем composer.json в родительскую директорию, которая не будет синкатся с хостом через
|
|
|
|
|
# volume на dev окружении. В entrypoint эта папка будет скопирована обратно.
|
|
|
|
|
COPY ./composer.json /var/www/composer.json
|
|
|
|
|
|
|
|
|
|
# Устанавливаем зависимости PHP
|
|
|
|
|
RUN cd .. \
|
|
|
|
|
&& composer install --no-interaction --no-suggest --no-dev --optimize-autoloader \
|
|
|
|
|
&& cd -
|
|
|
|
|
|
|
|
|
|
# Устанавливаем зависимости для Node.js
|
|
|
|
|
# Делаем это отдельно, чтобы можно было воспользоваться кэшем, если от предыдущего билда
|
|
|
|
|
# ничего не менялось в зависимостях
|
|
|
|
|
RUN mkdir -p /var/www/frontend
|
2016-05-30 02:08:19 +05:30
|
|
|
|
|
2016-10-02 03:50:40 +05:30
|
|
|
|
COPY ./frontend/package.json /var/www/frontend/
|
|
|
|
|
COPY ./frontend/scripts /var/www/frontend/scripts
|
|
|
|
|
COPY ./frontend/webpack-utils /var/www/frontend/webpack-utils
|
|
|
|
|
|
|
|
|
|
RUN cd ../frontend \
|
|
|
|
|
&& npm install \
|
|
|
|
|
&& cd -
|
|
|
|
|
|
|
|
|
|
# Наконец переносим все сорцы внутрь контейнера
|
2016-05-02 13:31:38 +05:30
|
|
|
|
COPY . /var/www/html
|
|
|
|
|
|
2016-05-30 02:08:19 +05:30
|
|
|
|
RUN mkdir -p api/runtime api/web/assets console/runtime \
|
2016-10-02 03:50:40 +05:30
|
|
|
|
&& chown www-data:www-data api/runtime api/web/assets console/runtime \
|
|
|
|
|
# Билдим фронт
|
|
|
|
|
&& cd frontend \
|
|
|
|
|
&& ln -s /var/www/frontend/node_modules $PWD/node_modules \
|
|
|
|
|
&& npm run build \
|
|
|
|
|
&& rm node_modules \
|
|
|
|
|
# Копируем билд наружу, чтобы его не затёрло volume в dev режиме
|
|
|
|
|
&& cp -r ./dist /var/www/dist \
|
|
|
|
|
&& cd -
|
|
|
|
|
|
|
|
|
|
# Экспозим всё под /var/www/html для дальнейшей связки с nginx
|
|
|
|
|
VOLUME ["/var/www/html"]
|
|
|
|
|
|
|
|
|
|
ENTRYPOINT ["entrypoint.sh"]
|
|
|
|
|
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"]
|