so what I'm trying to do is.
- build docker image
- run composer install within Dockerfile
- have the vendor folder with installed dependencies on my host machine aswell
What I acomplished since now is I managed to install dependencies on my container and everything runs fine. Although my vendor folder on my host machine is empty. So my IDE (phpstorm) doesn't recognize classes from installed packages (obviously) and this is the problem I need to solve.
What I tried:
- create a volume: it seems this copied the empty vendor folder and overwritten the vendor folder on container
- run composer install after starting container (this takes just too long time and it always installs all the packages again...not acceptable)
my docker-compose.yml:
services:
web:
build:
context: .
dockerfile: ./config/web/Dockerfile
image: web
container_name: WebServer
ports:
- "8081:80"
volumes:
- ./src:/var/www/notification
- /var/www/notification/vendor
networks:
- network
and my Dockerfile:
FROM php:7.4-apache
# Install GIT
RUN apt-get update &&
apt-get upgrade -y &&
apt-get install -y git &&
apt-get install -y nano &&
apt-get install -y libzip-dev &&
apt-get install -y zip unzip
# Install ext for PHP
RUN docker-php-ext-install pdo pdo_mysql zip
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Enable apache2 mod_rewrite module
RUN a2enmod rewrite
WORKDIR /var/www/smthing
COPY ./src/composer.json ./src/composer.lock ./
RUN composer install
Is there a way to sync this somehow automatically, without it taking forever?
Thanks in advance everyone :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…