'Laravel Docker Call to undefined function MyActionFunction
I'm new to docker and laravel. I'm trying to dockerize a laravel application, the source code is not mine. I used Sail for local tests, but now I want to build a production image. So I write a dockerfile with my deps:
FROM php:8.1.4-fpm-alpine3.15 as laravel-deps
RUN apk add --no-cache \
freetype-dev \
libpng-dev \
libjpeg-turbo-dev \
libtool \
libwebp-dev \
libzip-dev \
mariadb-dev \
pcre-dev ${PHPIZE_DEPS} \
zip \
&& pecl install redis \
&& docker-php-ext-configure gd --with-freetype \
&& docker-php-ext-install \
bcmath \
mysqli \
pcntl \
pdo_mysql \
zip \
-j$(nproc) gd \
&& docker-php-ext-enable \
bcmath \
pcntl \
redis \
zip \
&& apk del pcre-dev ${PHPIZE_DEPS} \
&& rm -rf /tmp/pear
#install composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
WORKDIR /srv/app
#delete when change logs in .env file
COPY --chown=www-data:www-data storage storage
COPY artisan .
COPY public/vendor/js-localization public/vendor/js-localization
COPY bootstrap bootstrap
COPY database database
COPY routes routes
COPY config config
COPY composer.json .
COPY composer.lock .
COPY app app
RUN composer install --optimize-autoloader --no-dev \
&& php artisan js-localization:export
FROM node:alpine as node-modules
WORKDIR /usr/app
COPY --from=laravel-deps /srv/app/public/vendor/js-localization public/vendor/js-localization
COPY .npmrc .
COPY resources resources
COPY package.json .
COPY package-lock.json .
COPY webpack.mix.js .
#isntalling node modules
RUN npm ci \
&& npm run prod
FROM laravel-deps as laravel-app
WORKDIR /srv/app
COPY .env .env
COPY public public
COPY resources resources
COPY --from=node-modules --chown=www-data:www-data /usr/app/public public
My problem comes out when I try to do php artisan migrate
in my PHP container:
Call to undefined function App\Actions\Myfunct\myfunct()
Also, when I access my app via browse I get a similar error, but in my view:
Call to undefined function brand_assets()
The crashed line in my view is:
<link rel="apple-touch-icon" sizes="57x57" href="<?php echo e(brand_assets('favicon/apple-icon-57x57.png')); ?>">
It is some lib or something I missing?
Update I think my autoload is not working. I ran the dump-autoload, and despite that I sill get the same error.
Solution 1:[1]
I found my error. I didn't COPY the helper dir into my Img. That's why my helpers didn't show up.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ivan Ochoa |