0

I have a docker image that installs phalcon onto a Docker image. Here is the Dockerfile:

FROM ubuntu:trusty
MAINTAINER Fernando Mayo <fernando@tutum.co>, Feng Honglin <hfeng@tutum.co>

# Install packages
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
  sudo apt-get -y install supervisor php5-dev libpcre3-dev gcc make php5-mysql git curl unzip apache2 libapache2-mod-php5 mysql-server php5-mysql pwgen php-apc php5-mcrypt php5-curl && \
  echo "ServerName localhost" >> /etc/apache2/apache2.conf

# Add image configuration and scripts
ADD start-apache2.sh /start-apache2.sh
ADD start-mysqld.sh /start-mysqld.sh
ADD run.sh /run.sh
RUN chmod 755 /*.sh
ADD my.cnf /etc/mysql/conf.d/my.cnf
ADD supervisord-apache2.conf /etc/supervisor/conf.d/supervisord-apache2.conf
ADD supervisord-mysqld.conf /etc/supervisor/conf.d/supervisord-mysqld.conf
ADD php.ini /etc/php5/cli/php.ini
ADD 000-default.conf /etc/apache2/sites-available/000-default.conf

ADD 30-phalcon.ini /etc/php5/apache2/conf.d/30-phalcon.ini
ADD 30-phalcon.ini /etc/php5/cli/conf.d/30-phalcon.ini

#RUN rm -rd /var/www/html/*
#RUN git clone --depth=1 git://github.com/phalcon/cphalcon.git /var/www/html/cphalcon
#RUN chmod 755 /var/www/html/cphalcon/build/install
#CMD["/var/www/html/cphalcon/build/install"]


RUN git clone --depth=1 git://github.com/phalcon/cphalcon.git /usr/local/src/cphalcon
RUN cd /usr/local/src/cphalcon/build && ./install ;\
    echo "extension=phalcon.so" > /etc/php5/mods-available/phalcon.ini ;\
    php5enmod phalcon


RUN sudo service apache2 stop
RUN sudo service apache2 start


# Remove pre-installed database
RUN rm -rf /var/lib/mysql/*

# Add MySQL utils
ADD create_mysql_admin_user.sh /create_mysql_admin_user.sh
RUN chmod 755 /*.sh

# config to enable .htaccess
RUN a2enmod rewrite

# Copy over private key, and set permissions
ADD .ssh /root/.ssh


# Get aws stuff
RUN curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
RUN unzip awscli-bundle.zip
RUN ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

RUN rm -rd /var/www/html/*
RUN git clone ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/Demo-Server /var/www/html

#Environment variables to configure php
ENV PHP_UPLOAD_MAX_FILESIZE 10M
ENV PHP_POST_MAX_SIZE 10M

# Add volumes for MySQL 
VOLUME  ["/etc/mysql", "/var/lib/mysql" ]

EXPOSE 80 3306
CMD ["/run.sh"]

When I run this Docker image locally it works fine, but when I run it on Elastic Beanstalk I get the error: PHP Fatal error: Class 'Phalcon\Loader' not found. To debug this I checked phpinfo() both locally and on the AWS server. Locally it shows all of the phalcon files installed, but on AWS I don't get any info about CPhalcon. How could the Docker image install Phalcon correctly when running on my local machine but not on Elastic Beanstalk?

Tyler Hilbert
  • 2,107
  • 7
  • 35
  • 55
  • Have you defined a docker volume in your local which your docker image is using to get the CPhalcon executables? You may need to install the same on the AWS instance and then define a volume for access. – Shibashis May 16 '16 at 16:12
  • @Shibashis: No I haven't used any local volumes. All the executables should come from: – Tyler Hilbert May 16 '16 at 17:18
  • RUN git clone --depth=1 git://github.com/phalcon/cphalcon.git /usr/local/src/cphalcon RUN cd /usr/local/src/cphalcon/build && ./install ;\ echo "extension=phalcon.so" > /etc/php5/mods-available/phalcon.ini ;\ php5enmod phalcon – Tyler Hilbert May 16 '16 at 17:18
  • I've done further debugging and I cannot find the phalcon.so file on the aws server, yet it is on the local instance. – Tyler Hilbert May 16 '16 at 17:50
  • Yes, but when you build the image it gets inside the docker file system. In your local can you bash into the docker container when its running and check if its available inside the running container. – Shibashis May 16 '16 at 17:52
  • @Shibashis I bashed in locally and it is available inside the running container. It looks like the ./install for cphalcon ran out of memory when installing on the server but didn't stop the Dockerfile build. – Tyler Hilbert May 16 '16 at 18:42
  • interesting. How is it running in local? if the install is not proper, I expect it to fail in local. Still fixing the memory issue is advisable. – Shibashis May 16 '16 at 18:48
  • @Shibashis: It doesn't run out of memory locally, only on the server. – Tyler Hilbert May 16 '16 at 19:21
  • Little confused, where did you see it run out of memory – Shibashis May 16 '16 at 19:34
  • I bashed into the container and ran the ./install command again to see what was happening. When I did it threw a make error. I then ran dmesg and it told me it ran out of memory. – Tyler Hilbert May 16 '16 at 19:40
  • Probably that's not right thing to do..you should not execute the install file again. – Shibashis May 16 '16 at 19:51
  • Do u have somewhere other than your local where you test this..Not on aws – Shibashis May 16 '16 at 19:52
  • @TylerHilbert, compiling the phalcon.so requires a lot of memory. Running out of memory is most likely the reason why phalcon wasn't installed correctly. Try increasing the available amount of PHP memory and give it another try. – Timothy May 17 '16 at 06:29

0 Answers0