visiblevc / wordpress-starter

A slightly less shitty wordpress development workflow
688 stars 167 forks source link

Installing XDebug and Mailhog #163

Closed yanickvanbarneveld closed 4 years ago

yanickvanbarneveld commented 4 years ago

Overview

What's your problem about?

I am trying to enable XDebug and Mailhog in the visiblevc/wordpress image by extending the Dockerfile. I don't get it to work, when I build I get the following error:

Cannot install, php_dir for channel "pecl.php.net" is not writeable by the current user
ERROR: Service 'wordpress' failed to build: The command '/bin/bash -o pipefail -c yes | pecl install xdebug     && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini     && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini     && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/xdebug.ini     && echo "xdebug.profiler_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini     && echo "xdebug.profiler_output_name=cachegrind.out.%t" >> /usr/local/etc/php/conf.d/xdebug.ini     && echo "xdebug.profiler_output_dir=/tmp" >> /usr/local/etc/php/conf.d/xdebug.ini     && echo "max_input_vars=2000" >> /usr/local/etc/php/conf.d/custom.ini     && rm -rf /usr/local/etc/php/conf.d/opcache-recommended.ini' returned a non-zero code: 1

Did someone else manage to achieve this?

docker-compose.yml & Dockerfile

FROM visiblevc/wordpress:latest

# # Mailhog
RUN curl --location --output /usr/local/bin/mhsendmail https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 && \
    chmod +x /usr/local/bin/mhsendmail

RUN echo 'sendmail_path="/usr/local/bin/mhsendmail --smtp-addr=mailhog:1025 --from=noreply@info.nl"' > /usr/local/etc/php/conf.d/mailhog.ini

# Xdebug
ENV XDEBUG_PORT 9000

RUN yes | pecl install xdebug \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.profiler_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.profiler_output_name=cachegrind.out.%t" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "xdebug.profiler_output_dir=/tmp" >> /usr/local/etc/php/conf.d/xdebug.ini \
    && echo "max_input_vars=2000" >> /usr/local/etc/php/conf.d/custom.ini \
    && rm -rf /usr/local/etc/php/conf.d/opcache-recommended.ini

EXPOSE 9000
version: "3.7"
services:
  wordpress:
    build:
      context: ./
      dockerfile: ./Dockerfile
    cap_add:
      - SYS_ADMIN
    devices:
      - /dev/fuse
    security_opt:
      - apparmor:unconfined
    ports:
      - 8080:80
      - 443:443
    environment:
      DB_NAME: wordpress
      DB_PASS: root
    volumes:
      - ./data/database:/data:cached
      - ./data/wordpress:/app:cached
      - ./build/themes:/app/wp-content/themes:cached
      - ./build/uploads:/app/wp-content/uploads:cached
      - ./build/plugins:/app/wp-content/plugins:cached
  db:
    image: mariadb:10
    volumes:
      - data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    ports:
      - 8000:80
  mailhog:
    image: mailhog/mailhog
    depends_on:
      - wordpress
    ports:
      - "1025:1025"
      - "8025:8025"
volumes:
  data: null
dsifford commented 4 years ago

Hey @yanickvanbarneveld.

Yeah, as it stands, the Dockerfile for this project isn't really extendable because of the use of the defined ENTRYPOINT.

I do see that there is a case to be made to change that however, so when I go to update for WP 5.3 (which is slated to release Nov 12), I'll make the adjustment to make this more extensible. That should cover for the XDebug portion of this issue...

As for the mailhog portion... Not totally sure without digging into the mailhog docs how it's supposed to hook up on the PHP side, but it seems like you're on the right track... Could just be due to the way the current Dockerfile is written as outlined above.

dsifford commented 4 years ago

This may or may not be helpful: https://github.com/mailhog/MailHog/wiki

dsifford commented 4 years ago

Hey @yanickvanbarneveld, digging into this now and I was mistaken.. we don't define the entrypoint at all. We define the CMD which is how it should be..

You should be able to fix your issue with extending our Dockerfile by simply adding CMD ["/run.sh"] at the end of your Dockerfile.

Let me know if that doesn't work and I'll reopen.

yanickvanbarneveld commented 4 years ago

Hi @dsifford, sorry for my late reaction. I am not sure though. I changed my Dockerfile to the following:

FROM visiblevc/wordpress:0.25.0-php7.3

RUN sudo curl --location --output /usr/local/bin/mhsendmail https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64
RUN echo 'sendmail_path="/usr/local/bin/mhsendmail --smtp-addr=mailhog:1025 --from=noreply@info.nl"' > sudo /usr/local/etc/php/conf.d/mailhog.ini
RUN echo 'sendmail_path = /usr/bin/mhsendmail --smtp-addr mailhog:1025' >> /usr/local/etc/php/php.ini

CMD ["/run.sh"]

Building the Dockerfile didn't give any errors but it still seems not to work and I am not really sure how to fix this. I know it hasn't to do anything with your awesome product but I can't find out.