In my previous article (https://brewedbrilliance.net/how-to-setup-phalcon-framework-in-a-docker-container/) I went through the steps needed for having a Dockerfile recipe ready to use for the phalcon framework and Apache based on Ubuntu. The end result was not so bad, however the docker image generated was around 8/900Mb that are good for a local development but wont be sustainable on the long run.
I managed to reduce the size down to ~300Mb, still big but improving, the Dockerfile is the follow
FROM alpine:latest
RUN apk add --no-cache \
apache2-proxy \
apache2-ssl \
apache2-utils \
curl \
git \
logrotate \
openssl \
git bash php php7-dev apache2 gcc \
libc-dev make php7-pdo php7-json \
php7-session php7-pecl-psr \
php7-apache2
RUN git clone --depth=1 "git://github.com/phalcon/cphalcon.git"
WORKDIR cphalcon/build
RUN ./install
RUN echo "extension=phalcon.so" > /etc/php7/conf.d/phalcon.ini
RUN rm -rf /cphalcon
RUN apk del libc-dev zlib-dev php7-dev libedit-dev musl-dev pcre2-dev ncurses-dev \
expat xz-libs curl musl-utils make libedit zlib ncurses-libs libstdc++ pcre git bash musl argon2-libs
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
WORKDIR /var/www/localhost/htdocs
RUN echo "<?php phpinfo(); ?>" > /var/www/localhost/htdocs/index.php
EXPOSE 80
CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]
The above dockerfile is dealing with Phalcon version 5 that is still in beta, if you want something more stable in a dev environment that will include Apache, PHP7 and Phalcon 4 then please visit this link
If you are interested in how to setup a Phalcon project step by step follow this link https://brewedbrilliance.net/phalcon-project-from-scratch-step-by-step/
If you enjoyed this article please share and help us grow.
Other articles of the same series
Share this content: