jeudi 26 octobre 2017

Class not found in autoload.php on line 14 on some docker hosts

I try to create dockerfile for laravel 5.5 application and nginx. I use similar to following dockerfile:

FROM richarvey/nginx-php-fpm:1.3.7

# we cannot directly work in /var/www/html beaouse in richarvey/nginx-php-fpm is VOLUME directive so if we create
# files in this directory - they will 'disappear' - so we use /tmp dir. 
WORKDIR /tmp/project

# due to docker cache
COPY ./composer.json .
RUN composer install --no-scripts --no-autoloader

ADD . .
RUN composer dump-autoload --optimize
RUN php artisan key:generate

ADD ./config/server-nginx.conf /etc/nginx/sites-available/default.conf

WORKDIR /var/www/html

CMD if [ -f index.php ]; then \
        rm index.php &&\            
        mv /tmp/project/* /var/www/html/ && \
        mv /tmp/project/.* /var/www/html/ | : &&\
        php artisan config:clear &&\
        php artisan cache:clear ; \
    fi &&\
    echo "Try connect to db and set up schema..." && \
    php artisan migrate --seed --force &&\
    /start.sh

My project/config/server-nginx.conf looks like that:

server {
    listen   80; ## listen for ipv4; this line is default and implied
    listen   [::]:80 default ipv6only=on; ## listen for ipv6


    root /var/www/html/public;
    index index.php index.html index.htm;

    server_name _;

    # Add stdout logging
    error_log /dev/stdout info;
    access_log /dev/stdout;


    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        include fastcgi_params; 

        ...            
    }

}

The problem is that everything works fine in my macOs and ubuntu, however my client which use Docker Claud and DigitalOcean have following problem after container run (so building step is fine, but after container run it is killed by docker - so in CMD dockerfile part):

Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found in /var/www/html/vendor/autoload.php:14
Stack trace:
#0 /var/www/html/artisan(18): require()



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2yNzRvi
via IFTTT

Aucun commentaire:

Enregistrer un commentaire