Deploy php application

Hi,

I would like to deploy php application. For that I use a Procfile like heroku and configure my application to use buildpack. I need some specific php extension like redis that is not in the buildpack default image so my application can’t work because of this missing extension.

First question, how can I specify extensions that I will need ?

If it’s not possible to customise / add some new php extensions I will need to use a Dockerfile. I have already a Dockerfile ready for production that I used for development purpose. This Dockerfile used php-fpm so I need a webserver behind like nginx to handler http requests. With docker compose it works fine, how can I route all my application traffic to an nginx webserver and forward php request to php-fpm container ?

Thanks a lot

Hi @Orkin ,

Buildpack is super useful to build and deploy very easily (perfect for development purposes) but this is not what we recommend at Qovery.

If you want to be able to manage routes, I advise to take a look here: Template to use a NGINX API gateway with Qovery. It should help you :slight_smile:

Pierre

Hi @Pierre_Mavro

I don’t think it’s what I want to do or I don’t understand how to handle it with nginx API gateway.

In my local environment I have to forward all php request to my api container :

server {
    listen 80 default;

    root /srv/app/public;

    access_log /var/log/nginx/application.access.log;

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location ~ ^/index\.php$ {
        fastcgi_pass api:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log";

        internal;
    }

    location ~ \.php$ {
        return 404;
    }
}

So this is not really a routing because all request received by nginx use fast cgi to forward on php-fpm. Maybe it’s possible with api gateway but it’s seem not so easy has expected :confused:

From heroku buildpack I can do it in a second

@Pierre_Mavro I tried with nginx API gateway, this is the routes.conf.template I used

location / {
    try_files $uri /index.php$is_args$args;
}

location ~ ^/index\.php$ {
    fastcgi_pass $API_PHP;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;

    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log";

    internal;
}

location ~ \.php$ {
    return 404;
}

The main problem with that is that I don’t have access to the index.php file that is in the api container. It works with docker-compose because they share the same volume.

Maybe it can work with Dockerfile target feature where I can have the nginx configuration in my php application repository or by sharing the same volume