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

WIP: Optimize Docker Images. #32

Open
wants to merge 2 commits into
base: feature/drupal9.5
Choose a base branch
from
Open
Show file tree
Hide file tree
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
22 changes: 12 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM drupal:9.5-php8.0
MAINTAINER [email protected]

# Install packages.
RUN apt-get update && apt-get install -y \
RUN apt-get clean && apt-get update && apt-get install -y \
zlib1g-dev \
libssl-dev \
libxml2-dev \
Expand Down Expand Up @@ -34,15 +34,7 @@ RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" &&
mv composer.phar /usr/local/bin/composer && \
php -r "unlink('composer-setup.php');"


# Install Open Social via composer.
RUN rm -f /var/www/composer.lock
RUN rm -rf /root/.composer

ADD composer.json /var/www/composer.json
WORKDIR /var/www/
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist --no-interaction --no-dev

WORKDIR /var/www/html/
RUN chown -R www-data:www-data *
Expand All @@ -52,7 +44,17 @@ RUN wget -O drush.phar https://github.com/drush-ops/drush-launcher/releases/down
chmod +x drush.phar && \
mv drush.phar /usr/local/bin/drush

RUN php -r 'opcache_reset();'
# GMP library.
RUN apt-get install -y libgmp-dev
RUN ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/local/include/
RUN docker-php-ext-configure gmp
RUN docker-php-ext-install gmp

# Redis.
RUN pecl install redis \
&& docker-php-ext-enable redis

# Fix shell.
RUN echo "export TERM=xterm" >> ~/.bashrc

RUN php -r 'opcache_reset();'
22 changes: 2 additions & 20 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
FROM goalgorilla/open_social_docker:latest
FROM goalgorilla/open_social_docker:latest-experimental
MAINTAINER [email protected]

# Specify the work directory.
WORKDIR /var/www/

ADD php.ini /usr/local/etc/php/php.ini

### CI SPECIFIC - START ###

# GMP library.
RUN apt-get install -y libgmp-dev
RUN ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/local/include/
RUN docker-php-ext-configure gmp
RUN docker-php-ext-install gmp

# Install composer dependencies.
RUN composer install --prefer-dist --no-interaction

# Unfortunately, adding the composer vendor dir to the PATH doesn't seem to work. So:
RUN ln -s /root/.composer/vendor/bin/behat /usr/local/bin/behat
RUN ln -s /root/.composer/vendor/bin/phpunit /usr/local/bin/phpunit

ADD php.ini /usr/local/etc/php/php.ini
### CI SPECIFIC - END ###

RUN php -r "opcache_reset();"
47 changes: 2 additions & 45 deletions dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
FROM goalgorilla/open_social_docker:latest
FROM goalgorilla/open_social_docker:latest-experimental
MAINTAINER [email protected]

### CI SPECIFIC - START ###
### - Making changes here? Also apply in ../ci/Dockerfile ###

# Specify the work directory.
WORKDIR /var/www/

# Install composer dependencies.
RUN composer install --prefer-dist --no-interaction

# Unfortunately, adding the composer vendor dir to the PATH doesn't seem to work. So:
RUN ln -s /root/.composer/vendor/bin/behat /usr/local/bin/behat
RUN ln -s /root/.composer/vendor/bin/phpunit /usr/local/bin/phpunit

### CI SPECIFIC - END ###

### DEV SPECIFIC - START ###

ADD php.ini /usr/local/etc/php/php.ini

# GMP library.
RUN apt-get install -y libgmp-dev
RUN ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/local/include/
RUN docker-php-ext-configure gmp
RUN docker-php-ext-install gmp

# Xdebug.
RUN pecl install xdebug-3.1.1 && \
docker-php-ext-enable xdebug && \
Expand All @@ -35,28 +14,6 @@ RUN pecl install xdebug-3.1.1 && \
sed -i '1 a xdebug.client_host=host.docker.internal' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
sed -i '1 a xdebug.idekey=PHPSTORMi' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

# Blackfire
# @todo Fix PHP 8 based blackfire installation
#RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
# && architecture=$(uname -m) \
# && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/$architecture/$version \
# && mkdir -p /tmp/blackfire \
# && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
# && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so \
# && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8307\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
# && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz

RUN php -r "opcache_reset();"

# @todo Remove these steps as it is not required for latest Docker desktop.
# Contains the Mac hack to get the permissions to work for development.
# Set user 1000 and group staff to www-data, enables write permission.
# https://github.com/boot2docker/boot2docker/issues/581#issuecomment-114804894
#RUN usermod -u 1000 www-data
#RUN usermod -G staff www-data

### DEV SPECIFIC - END ###

# Redis.
RUN pecl install redis \
&& docker-php-ext-enable redis
RUN php -r "opcache_reset();"