سلام دوستان
من میخوام laravel رو با apache و redis و phpmyadmin و redis-viewer روی docker بیارم بالا.
ولی مشکل اینجاست بعد از composer install و autoload هیچ پکیجی توی vendor ریخته نمیشه و همش ارور میده:
Warning: require(/var/www/html/public/../vendor/autoload.php): Failed to open stream: No such file or directory in /var/www/html/public/index.php on line 34
Fatal error: Uncaught Error: Failed opening required '/var/www/html/public/../vendor/autoload.php' (includepath='.:/usr/local/lib/php') in /var/www/html/public/index.php:34 Stack trace: #0 /var/www/html/server.php(21): requireonce() #1 {main} thrown in /var/www/html/public/index.php on line 34
و اینم بگم که frontend و backend پروژه هر دو laravel هستن و توی هردوشون Dockerfile هست
Dockerfile
# Base image
FROM php:8.1-apache
# Set working directory
WORKDIR /var/www/html
# Install system dependencies
RUN apt-get update && apt-get install -y \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip
# Enable mod_rewrite
RUN a2enmod rewrite
# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Copy the Laravel composer.json and composer.lock files
COPY . /var/www/html
# Install Composer dependencies
RUN composer install
# Dump the autoloader
RUN composer dump-autoload
# Generate Laravel application key
RUN php artisan key:generate
# Delay migration until the database service is ready
CMD php artisan migrate --force && apache2-foreground
docker-compose.yml
version: '3.8'
services:
db:
container_name: db
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: chameleons
MYSQL_DATABASE: crm
ports:
- "9906:3306"
phpmyadmin:
container_name: phpmyadmin
image: phpmyadmin/phpmyadmin
environment:
PMA_HOST: db
PMA_PORT: 3306
MYSQL_ROOT_PASSWORD: chameleons
ports:
- 8080:80
depends_on:
- db
redis:
container_name: redis
image: redis:6.2
ports:
- 6379:6379
redis-viewer:
container_name: redis-viewer
image: rediscommander/redis-commander:latest
ports:
- 8081:8081
environment:
- REDIS_HOSTS=redis
back-end:
container_name: back-end
build:
context: ./backend
dockerfile: Dockerfile
links:
- db
- redis
volumes:
- ./backend:/var/www/html/
ports:
- 8000:80
depends_on:
- db
- phpmyadmin
- redis
- redis-viewer
front-end:
container_name: front-end
build:
context: ./frontend
dockerfile: Dockerfile
volumes:
- ./frontend:/var/www/html/
ports:
- 7000:80
depends_on:
- db
- phpmyadmin
- redis
- redis-viewer
.env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=crm
DB_USERNAME=root
DB_PASSWORD=chameleons
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
به محمدرضا فلکی کمک کنید تا مشکل خودش را حل کند؛ اینطور میتوانیم با هم پیشرفت کنیم.
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟