How to setup Phalcon 5 framework in a Docker container V2

In my previous article (https://keepforyourself.com/coding/php/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

https://keepforyourself.com/coding/php/dev-environment-in-docker-with-apache-php7-phalcon/

If you are interested in how to setup a Phalcon project step by step follow this link https://keepforyourself.com/coding/phalcon-project-from-scratch-step-by-step/

If you enjoyed this article please share and help us grow.

Learning PHP – Introduction

Learning PHP – print and echo

Learning PHP – The variables

Learning PHP – if else

Learning PHP – Arrays

Learning PHP – The loops

d3

d3 is an experienced Software Engineer/Developer/Architect/Thinker with a demonstrated history of working in the information technology and services industry. Really passionate about technology, programming languages and problem solving. He doesn't like too much the self celebration and prefers to use that time doing something useful ...i.e. coding

You may also like...