Description:
I am facing this issue whilst working with a Sail Laravel application . I am facing this issue with my docker containers. The bug wasn’t appearing before , but is suddenly appearing now.
I had tried to prune all the dockers and also search on the net for the solution .
I have tried to install php extensions gmp and bcmath in my dockerfile , yet i am still facing the issue.
Here’s my dockerfile:
FROM --platform=linux/arm64 composer:latest
WORKDIR /var/www/html
COPY composer* ./
COPY .env .env
RUN composer install
--no-interaction
--prefer-dist
--ignore-platform-reqs
--optimize-autoloader
--apcu-autoloader
--ansi
--no-scripts
FROM node:18
WORKDIR /var/www/html
COPY package.json ./package.json
COPY yarn.lock ./yarn.lock
COPY .yarnrc.yml ./.yarnrc.yml
COPY .yarn ./.yarn
COPY . ./
RUN rm -rf node_modules
RUN yarn
RUN rm -rf vendor
COPY --from=0 /var/www/html/vendor vendor
RUN yarn build
RUN rm -rf node_modules
FROM php:8.1.9-cli-alpine
ENV CONTAINER_MODE=prod
ENV NODE_OPTIONS="--require /var/www/html/.pnp.cjs"
RUN echo https://dl-cdn.alpinelinux.org/alpine/v3.15/main >> /etc/apk/repositories &&
echo https://dl-cdn.alpinelinux.org/alpine/v3.15/community >> /etc/apk/repositories &&
echo https://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories
RUN apk update &&
apk --no-cache upgrade &&
apk --no-cache add bash git linux-headers sudo python3 which openssh openssl-dev rsyslog rsyslog-tls
libxml2-dev oniguruma-dev autoconf gcc php-gmp g++ vim supervisor
make freetype-dev libjpeg-turbo-dev libpng-dev libzip-dev gnu-libiconv mysql-client
php81-pecl-ssh2 curl-dev poppler-utils $PHPIZE_DEPS
//Install php extensions
RUN docker-php-ext-install bcmath gmp
RUN pecl install -o -f redis pcov grpc excimer
&& rm -rf /tmp/pear
WORKDIR /tmp
RUN git clone https://github.com/swoole/swoole-src.git &&
cd swoole-src &&
git checkout v5.0.0 &&
phpize &&
./configure --enable-openssl --enable-swoole-curl --enable-http2 --enable-mysqlnd &&
make -j 4 && make install
WORKDIR /var/www/html
RUN touch /usr/local/etc/php/conf.d/swoole.ini &&
echo 'extension=swoole.so' > /usr/local/etc/php/conf.d/swoole.ini
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install mbstring xml pcntl gd zip pdo pdo_mysql bcmath soap
RUN docker-php-ext-enable mbstring xml gd zip pcntl bcmath pdo pdo_mysql soap redis pcov grpc
RUN cp -R /etc/php81/conf.d/* /usr/local/etc/php/conf.d/
RUN cp /usr/lib/php81/modules/*.so /usr/local/lib/php/extensions/no-debug-non-zts-20210902/
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php
COPY deployment/php.ini /usr/local/etc/php/conf.d/octane.ini
COPY deployment/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
RUN curl -o /etc/papertrail-bundle.pem https://papertrailapp.com/tools/papertrail-bundle.pem
COPY deployment/papertrail.conf /etc/rsyslog.d/20-papertrail.conf
RUN addgroup octanegroup
RUN adduser -D octaneuser
RUN addgroup octaneuser octanegroup
COPY --from=1 --chown=octaneuser:octanegroup /var/www/html/ ./
RUN chmod -R ug+rwx ./
RUN chmod +x deployment/entrypoint.sh
RUN chmod +x deployment/preStop.sh
USER octaneuser
ENTRYPOINT ["bash", "-l", "deployment/entrypoint.sh"]
EXPOSE 8000
Expected Behavior:
The application to be created so that it can run.
Actual Behavior:
Getting this laravel logs constantly:
[2024-03-15 14:58:01] local.ERROR:
1. Missing math extension for Hashids, install either bcmath or gmp.
{"exception":"[object] (RuntimeException(code: 0): Missing math extension for Hashids, install either bcmath or gmp. at /var/www/html/vendor/hashids/hashids/src/Hashids.php:297) [stacktrace] #0 /var/www/html/vendor/hashids/hashids/src/Hashids.php(42): Hashids\\Hashids->getMathExtension() #1 /var/www/html/vendor/ashallendesign/short-url/src/Classes/KeyGenerator.php(23): Hashids\\Hashids->__construct() 2 /var/www/html/vendor/ashallendesign/short-url/src/Classes/Builder.php(192): AshAllenDesign\\ShortURL\\Classes\\KeyGenerator->__construct() 3 /var/www/html/vendor/ashallendesign/short-url/src/Providers/ShortURLProvider.php(22): AshAllenDesign\\ShortURL\\Classes\\Builder->__construct() 4 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(908): AshAllenDesign\\ShortURL\\Providers\\ShortURLProvider->AshAllenDesign\\ShortURL\\Providers\\{closure}() 5 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(795): Illuminate\\Container\\Container->build() 6 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(955): Illuminate\\Container\\Container->resolve() 7 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(731): Illuminate\\Foundation\\Application->resolve() 8 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(940): Illuminate\\Container\\Container->make() 9 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(1454): Illuminate\\Foundation\\Application->make() 10 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(237): Illuminate\\Container\\Container->offsetGet() 11 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(208): Illuminate\\Support\\Facades\\Facade::resolveFacadeInstance() 12 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(349): Illuminate\\Support\\Facades\\Facade::getFacadeRoot() #13 /var/www/html/vendor/ashallendesign/short-url/routes/web.php(6): Illuminate\\Support\\Facades\\Facade::__callStatic() #14 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php(152): require('...') #15 /var/www/html/vendor/ashallendesign/short-url/src/Providers/ShortURLProvider.php(46): Illuminate\\Support\\ServiceProvider->loadRoutesFrom() #16 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): AshAllenDesign\\ShortURL\\Providers\\ShortURLProvider->boot() #17 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #18 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure() #19 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod() #20 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\\Container\\BoundMethod::call() #21 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1028): Illuminate\\Container\\Container->call() #22 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1009): Illuminate\\Foundation\\Application->bootProvider() #23 [internal function]: Illuminate\\Foundation\\Application->Illuminate\\Foundation\\{closure}() #24 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1008): array_walk() #25 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\\Foundation\\Application->boot() #26 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(261): Illuminate\\Foundation\\Bootstrap\\BootProviders->bootstrap() #27 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(447): Illuminate\\Foundation\\Application->bootstrapWith() #28 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(199): Illuminate\\Foundation\\Console\\Kernel->bootstrap() #29 /var/www/html/artisan(35): Illuminate\\Foundation\\Console\\Kernel->handle() #30 {main} "}
Environment:
Operating System: MacOS Sonoma
Version: 14.2
Other relevant software or dependencies: Laravel, Sail, Docker
Would appreciate if I can get some assistance as soon as possible ?