You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For those who are curious, and want to use this excellent Docker image....
Change the php-base version of Alpine
Change the Roadrunner version (this dies with permission errors otherwise)
Change the Laravel version variable
FROM php:8.1.12-cli-alpine3.16 as php-base
WORKDIR /srv/laravel
RUN apk add --no-cache $PHPIZE_DEPS autoconf libzip-dev zip unzip wget curl && \
docker-php-ext-install bcmath ctype pcntl sockets zip && \
rm -rf /var/www && \
chown -R www-data:www-data /srv/laravel
# This stage is so that we can build up everything that doesn't require Laravel
# so as to not bust the caching for those items.
FROM php-base as octane-base
COPY --from=spiralscout/roadrunner:latest /usr/bin/rr /usr/bin/rr
# This really shouldn't be modified, so we aren't advertising the env variable.
# It allows us to globally install chokidar without modifying the Laravel package.json.
ENV NODE_PATH "/home/www-data/.npm-global/lib/node_modules"
RUN apk add --no-cache nodejs npm && \
mkdir "/home/www-data/.npm-global/" && \
npm config set prefix "/home/www-data/.npm-global/" && \
npm install -g chokidar
# Here we have a build container so that it is not necessary to pull composer into
# the final container. We are going to create a new Laravel project and install Octane.
FROM php-base as laravel
ARG LARAVEL_VERSION="9.*"
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
RUN cd /srv && \
composer create-project laravel/laravel="${LARAVEL_VERSION}" laravel && \
cd /srv/laravel && \
composer require laravel/octane spiral/roadrunner && \
php artisan octane:install --server="roadrunner" && \
rm "/srv/laravel/.env"
# This is our final container. We will install the RoadRunner binary and copy over
# our built version of Laravel.
FROM octane-base
USER www-data
COPY --from=laravel --chown=www-data:www-data /srv/laravel/ /srv/laravel/
# Allow the user to specify RoadRunner options via ENV variables.
ENV ROADRUNNER_MAX_REQUESTS "500"
ENV ROADRUNNER_WATCH $false
ENV ROADRUNNER_WORKERS "auto"
# Expose the ports that Octane is using.
EXPOSE 8000
# Run RoadRunner
CMD if [[ -z $ROADRUNNER_WATCH ]] ; then \
php artisan octane:start --server="roadrunner" --host="0.0.0.0" --workers=${ROADRUNNER_WORKERS} --max-requests=${ROADRUNNER_MAX_REQUESTS} ; \
else \
php artisan octane:start --server="roadrunner" --host="0.0.0.0" --workers=${ROADRUNNER_WORKERS} --max-requests=${ROADRUNNER_MAX_REQUESTS} --watch ; \
fi
# Check the health status using the Octane status command.
HEALTHCHECK CMD php artisan octane:status --server="roadrunner"
laravel:
build:
context: ./docker/dockerfile: laravel.Dockerfilerestart: unless-stoppedports:
- '127.0.0.1:8000:8000'# run on port 8000 localhost only, port 8000 on the containerenvironment:
ROADRUNNER_MAX_REQUESTS: 250ROADRUNNER_WATCH: "yes"ROADRUNNER_WORKERS: 6APP_NAME: "Example"APP_ENV: "local"volumes:
- ./laravel-src:/srv/laravel
The text was updated successfully, but these errors were encountered:
For those who are curious, and want to use this excellent Docker image....
For a list of PHP extensions you can install in Alpine: https://gist.github.com/chronon/95911d21928cff786e306c23e7d1d3f3 .
If you need to add others (e.g. curl, mbstring), you will need the development files. Find them here: https://pkgs.alpinelinux.org/packages
For MongoDB and Redis you will need to install from PECL, which requires
autoconf
and$PHPIZE_DEPS
:Another issue here is the directory binding. The latest version of Docker wants volumes.
Example Compose setup:
The text was updated successfully, but these errors were encountered: