Unit: The module to run "php" is not found among the available application modules
I've been using the image 8.2 for a while and I'm trying to move to unit-8.2, however I'm getting an invalid configuration error.
app-1 | 2024/08/19 03:07:24 [info] 1#1 unit 1.32.1 started
app-1 | 2024/08/19 03:07:24 [info] 36#36 discovery started
app-1 | 2024/08/19 03:07:24 [notice] 36#36 module: php 8.2.22 "/usr/lib/unit/modules/php.unit.so"
app-1 | 2024/08/19 03:07:24 [notice] 36#36 incompatible module /usr/lib/unit/modules/php.unit.so
app-1 | 2024/08/19 03:07:24 [info] 1#1 controller started
app-1 | 2024/08/19 03:07:24 [notice] 1#1 process 36 exited with code 0
app-1 | 2024/08/19 03:07:24 [info] 38#38 router started
app-1 | 2024/08/19 03:07:24 [alert] 37#37 the previous configuration is invalid: The module to run "php" is not found among the available application modules.
app-1 | 2024/08/19 03:07:24 [info] 38#38 OpenSSL 3.0.2 15 Mar 2022, 30000020
I'm not doing anything interesting on my Dockerfile, but just in case, here it is:
# syntax = docker/dockerfile:experimental
ARG PHP_VERSION=8.2
ARG NODE_VERSION=20
FROM fideloper/fly-laravel:unit-${PHP_VERSION} as base
# PHP_VERSION needs to be repeated here
# See https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
ARG PHP_VERSION
LABEL fly_launch_runtime="laravel"
# copy application code, skipping files based on .dockerignore
COPY . /var/www/html
RUN composer install --optimize-autoloader --no-dev \
&& mkdir -p storage/logs \
&& chown -R www-data:www-data /var/www/html \
&& if [ -d .fly ]; then \
cp .fly/entrypoint.sh /entrypoint; \
chmod +x /entrypoint; \
fi
# Multi-stage build: Build static assets
# This allows us to not include Node within the final container
FROM node:${NODE_VERSION} as node_modules_go_brrr
RUN mkdir -p /app
WORKDIR /app
COPY . .
COPY --from=base /var/www/html/vendor /app/vendor
# Use yarn or npm depending on what type of
# lock file we might find. Defaults to
# NPM if no lock file is found.
# Note: We run "production" for Mix and "build" for Vite
RUN if [ -f "vite.config.js" ]; then \
ASSET_CMD="build"; \
else \
ASSET_CMD="production"; \
fi; \
if [ -f "yarn.lock" ]; then \
yarn install --frozen-lockfile; \
yarn $ASSET_CMD; \
elif [ -f "pnpm-lock.yaml" ]; then \
corepack enable && corepack prepare pnpm@latest-8 --activate; \
pnpm install --frozen-lockfile; \
pnpm run $ASSET_CMD; \
elif [ -f "package-lock.json" ]; then \
npm ci --no-audit; \
npm run $ASSET_CMD; \
else \
npm install; \
npm run $ASSET_CMD; \
fi;
# From our base container created above, we
# create our final image, adding in static
# assets that we generated above
FROM base
# Packages like Laravel Nova may have added assets to the public directory
# or maybe some custom assets were added manually! Either way, we merge
# in the assets we generated above rather than overwrite them
COPY --from=node_modules_go_brrr /app/public /var/www/html/public-npm
RUN rsync -ar /var/www/html/public-npm/ /var/www/html/public/ \
&& rm -rf /var/www/html/public-npm \
&& chown -R www-data:www-data /var/www/html/public
EXPOSE 8080
I've modified the entrypoint to:
#!/usr/bin/env sh
# Run user scripts, if they exist
for f in /var/www/html/.fly/scripts/*.sh; do
# Bail out this loop if any script exits with non-zero status code
bash "$f" -e
done
chown -R www-data:www-data /var/www/html
if [ $# -gt 0 ]; then
# If we passed a command, run it as root
exec "$@"
else
# exec supervisord -c /etc/supervisor/supervisord.conf
exec unitd --no-daemon --log /dev/stdout
fi
I'm quite sure this is a user error, but I can't figure it out, would love some guidance.
IIRC if you’re using nginx unit, this is likely due to Unit releasing a new version of Unit, which this repo hasn’t incorporated.
We never supported unit officially (it was added as an experiment), so the repo hasn’t kept up with new Unit versions.
However PRs are welcome for that.
it’s probably just updating this like to the latest version https://github.com/fly-apps/laravel-docker/blob/main/src/Dockerfile-unit#L4
Which I think is 1.32.1 (based on this repo https://github.com/nginx/unit ).
It’s a bit hard to see because I’m on my phone and github’s interface hides releases (?!) on mobile.
Thanks for the replay @fideloper I tried for a bit but when back to php-fpm. Closing the issue as this is an experiment.