I want to copy all files during the installation process in docker-compose.yml
file.
If I run:
$ git clone https://github.com/laravel/laravel.git laravel-app
$ cd laravel-app
$ docker run --rm -v $(pwd):/app composer install
It will copy all new files from container to host during the installation process in the docker container.
So I will see new vendor
folder and composer.lock
file in my laravel-app
directory after installation.
But if I setup volume in docker-compose.yml
:
version: '3'
services:
#PHP Service
app:
build:
context: .
dockerfile: Dockerfile
container_name: app
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
And then setup installation process in Dockerfile
:
FROM php:7.4.4-fpm
# Set working directory
WORKDIR /var/www
# Install dependencies
RUN apt-get update && apt-get install -y
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Copy existing application directory contents
COPY . /var/www
# Install composer.json dependencies
RUN composer install # <<-- !this one!
It will not copy vendor
folder and composer.lock
file back to my host.
Hot to make it happen?