Hello,
The compose file and Dockerfile are as follows:
services:
portal:
build:
context: /home/dev/portal
dockerfile: Dockerfile
container_name: portal
entrypoint: ["/usr/local/bin/entrypoint.sh"]
command: ["php-fpm"]
environment:
APP_ENV: local
APP_DEBUG: "true"
DB_HOST: db
DB_PORT: 3306
DB_DATABASE: laravel
DB_USERNAME: root
DB_PASSWORD: 123456
USER_ID: ${USER_ID:-1000}
GROUP_ID: ${GROUP_ID:-1000}
OPCACHE_ENABLE: 1
OPCACHE_MEMORY_CONSUMPTION: 128
OPCACHE_MAX_ACCELERATED_FILES: 10000
OPCACHE_REVALIDATE_FREQ: 60
volumes:
- /home/docki/dev/portal:/var/www
ports:
- "127.0.0.1:9000:9000"
And:
FROM php:8.3-fpm
RUN apt update && apt install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
libonig-dev \
libzip-dev \
zip unzip git curl net-tools ncat iputils-ping \
&& apt clean && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install opcache
COPY opcache.ini /usr/local/etc/php/conf.d/opcache.ini
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install pdo_mysql mbstring zip exif pcntl gd
RUN pecl install xdebug && docker-php-ext-enable xdebug
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
ARG USER_ID=999
ARG GROUP_ID=995
RUN groupadd -g ${GROUP_ID} www && \
useradd -u ${USER_ID} -g www -ms /bin/bash www
WORKDIR /var/www
COPY --chown=www:www entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
ENV APP_ENV=local
ENV APP_DEBUG=true
ENV XDEBUG_MODE=develop,debug
COPY www.conf /usr/local/etc/php-fpm.d/www.conf
USER www
EXPOSE 9000
The entrypoint.sh
file is also as follows:
#!/bin/bash
# 1. Check and copy files if directory is empty
if [ "$(ls -A /var/www)" ]; then
echo "Directory is not empty, skipping copy"
else
echo "Directory is empty, copying files"
cp -R /tmp/app/. /var/www/
fi
# 2. Composer installation
if [ -f "/var/www/composer.json" ]; then
cd /var/www
echo "Installing composer dependencies..."
composer install --no-interaction --optimize-autoloader --no-scripts
fi
# 3. Generate APP_KEY if missing
if [ -z "$(grep 'APP_KEY=base64' /var/www/.env)" ]; then
echo "Generating APP_KEY..."
cd /var/www
php artisan key:generate --force
fi
# 4. Database migrations and seeding
echo "Running database migrations..."
php artisan migrate --force
# 5. Cache optimization (production only)
if [ "$APP_ENV" = "production" ]; then
echo "Optimizing Laravel for production..."
php artisan config:cache
php artisan route:cache
php artisan view:cache
else
echo "Clearing development caches..."
php artisan config:clear
php artisan route:clear
php artisan view:clear
fi
# 6. Fix permissions
echo "Setting permissions..."
chown -R www:www /var/www/storage
chown -R www:www /var/www/bootstrap/cache
chown -R www:www /var/www/vendor
chmod -R 775 /var/www/storage
chmod -R 775 /var/www/bootstrap/cache
chmod -R 775 /var/www/vendor
# 7. Link storage if needed
if [ ! -L "/var/www/public/storage" ]; then
echo "Creating storage link..."
php artisan storage:link
fi
# 8. Run the main command
exec "$@"
Some parts of the project are not working because of VentsController
and the following command has no output:
# docker exec -it portal php artisan route:list | grep vents
Any idea welcome.
Thank you.