Laravel Octane is still Laravel but on steroids. It claims that it can run your applications at supersonic speed. Sounds great! It’s docker time!
We have two choices on what server to use: Swoole or RoadRunner. I don’t want headaches so we will go with Swoole. It is only a PHP extension so it’s really easy to run it with PHP. For benchmarks, you can do your research yourself, but Swoole is in par with RoadRunner in terms of the number of requests it can handle.
Let’s proceed first on creating our base image that is running PHP with Swoole already installed.
I already created a Github repository for this and pushed it on to the Dockerhub. See the following links
And now let’s extend it for our Laravel usecase.
FROM jcfrane/php:8.2-swoole
RUN curl -sS https://getcomposer.org/installer | php — –install-dir=/usr/local/bin –filename=composer
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash – && \
apt-get install -y nodejs \
build-essential && \
node –version && \
npm –version
RUN npm install –save-dev chokidar
COPY ./opt/php/php.ini /usr/local/etc/php/conf.d/php.ini
WORKDIR /var/www/html
COPY ./ .
RUN composer install –optimize-autoloader –no-dev
COPY /opt/php/entrypoint.sh /usr/local/bin/
COPY /opt/php/queue-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/queue-entrypoint.sh
EXPOSE 8000
ENTRYPOINT [“entrypoint.sh”]
CMD [“php”, “artisan”, “octane:start”, “–host=0.0.0.0”, “–watch”]
[/sourcecode]
0 Comments