Im startig my journal with docker.
I made docker-compose.yml that starts following services:
- nginx
- PHP 8.1
I setup site to display and read php files, everything is ok. But right now I don’t know whats next. I want to install laravel with composer and NPM. How to run it together in that way I can user "composer install", "composer update" in every project.
This is my docker-compose.yml:
services:
nginx:
container_name: nginx_tst
image: nginx:latest
networks:
- php
ports:
- "8080:80"
volumes:
- "./nginx-conf:/etc/nginx/conf.d"
- "./:/usr/share/nginx/html"
php:
container_name: php_tst
image: php:8.1-fpm
networks:
- php
volumes:
- "./:/usr/share/nginx/html"
working_dir: /
networks:
php:
Edit:
I Switched to Laravel Sail, it makes everything by itself
2
Answers
Add command attribute to the php service. Using that you can execute compose install and update commands and etc…
Follow this link to know how to execute multiple commands
Docker Compose – How to execute multiple commands?
You can use something like this.
You can go inside the container
and then install & run composer
install & run nvm