Skip to content

Commit

Permalink
Merge pull request #4459 from genzouw/feature/simplify_dockerfile
Browse files Browse the repository at this point in the history
Dockerfileを軽量化。レイヤを減らしてビルド速度を改善。
  • Loading branch information
Kiyotaka Oku authored Feb 7, 2020
2 parents ed5759a + 6efa177 commit 7c101a1
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ FROM php:7.3-apache-stretch

ENV APACHE_DOCUMENT_ROOT /var/www/html

RUN echo "deb http://cdn.debian.net/debian/ stretch main contrib non-free" > /etc/apt/sources.list.d/mirror.jp.list
RUN echo "deb http://cdn.debian.net/debian/ stretch-updates main contrib" >> /etc/apt/sources.list.d/mirror.jp.list

RUN /bin/rm /etc/apt/sources.list
RUN /bin/rm /etc/apt/sources.list \
&& { \
echo 'deb http://cdn.debian.net/debian/ stretch main contrib non-free'; \
echo 'deb http://cdn.debian.net/debian/ stretch-updates main contrib'; \
} > /etc/apt/sources.list.d/mirror.jp.list

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
Expand All @@ -26,27 +27,26 @@ RUN apt-get update \
locales \
ssl-cert \
unzip \
vim \
zlib1g-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& echo "en_US.UTF-8 UTF-8" >/etc/locale.gen \
&& locale-gen
&& locale-gen \
;

RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install -j$(nproc) zip gd mysqli pdo_mysql opcache intl pgsql pdo_pgsql
&& docker-php-ext-install -j$(nproc) zip gd mysqli pdo_mysql opcache intl pgsql pdo_pgsql \
;

RUN pecl install apcu && echo "extension=apcu.so" > /usr/local/etc/php/conf.d/apc.ini

RUN mkdir -p ${APACHE_DOCUMENT_ROOT}
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf

RUN a2enmod rewrite
RUN a2enmod headers
RUN mkdir -p ${APACHE_DOCUMENT_ROOT} \
&& sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf \
&& sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf \
;

RUN a2enmod rewrite headers ssl
# Enable SSL
RUN a2enmod ssl
RUN ln -s /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-enabled/default-ssl.conf
EXPOSE 443

Expand All @@ -55,24 +55,24 @@ RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# Override with custom configuration settings
COPY dockerbuild/php.ini $PHP_INI_DIR/conf.d/

RUN curl -sS https://getcomposer.org/installer \
| php \
&& mv composer.phar /usr/bin/composer \
&& composer config -g repos.packagist composer https://packagist.jp \
&& composer global require hirak/prestissimo

ENV COMPOSER_ALLOW_SUPERUSER 1

COPY . ${APACHE_DOCUMENT_ROOT}

WORKDIR ${APACHE_DOCUMENT_ROOT}

RUN composer install \
--no-scripts \
--no-autoloader \
--no-dev -d ${APACHE_DOCUMENT_ROOT} \
ENV COMPOSER_ALLOW_SUPERUSER 1

RUN curl -sS https://getcomposer.org/installer \
| php \
&& mv composer.phar /usr/bin/composer \
&& composer config -g repos.packagist composer https://packagist.jp \
&& composer global require hirak/prestissimo \
&& composer install \
--no-scripts \
--no-autoloader \
--no-dev -d ${APACHE_DOCUMENT_ROOT} \
&& chown -R www-data:www-data ${APACHE_DOCUMENT_ROOT} \
&& chown www-data:www-data /var/www
&& chown www-data:www-data /var/www \
;

USER www-data
RUN composer dumpautoload -o --apcu --no-dev
Expand Down

0 comments on commit 7c101a1

Please sign in to comment.