Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfileを軽量化。レイヤを減らしてビルド速度を改善。 #4459

Merged
merged 1 commit into from
Feb 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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