[英]Docker PHP Composer
I've the following docker-compose file, and need some help with PHP composer part commented below: 我有以下docker-compose文件,并且需要在以下评论的PHP作曲家部分中寻求帮助:
version: '3'
services:
proxy:
image: jwilder/nginx-proxy
container_name: proxy
ports:
- '80:80'
- '443:443'
volumes:
- './certs:/etc/nginx/certs'
- '/var/run/docker.sock:/tmp/docker.sock:ro'
restart: always
web:
image: 'nginx:latest'
container_name: nginx
volumes:
- './volume1:/volume1'
- './volume2:/volume2'
- './volume3:/volume3'
- './site.conf:/etc/nginx/conf.d/site.conf'
environment:
- 'VIRTUAL_HOST=host1.local,host2.local,host3.local'
restart: always
php:
build: .
container_name: php
volumes:
- './volume1:/volume1'
- './volume2:/volume2'
- './volume3:/volume3'
restart: always
# Start How TODO this?
composer:
image: 'composer:latest'
container_name: composer
command: install
volumes:
- './volume1:/app'
- './volume2:/app'
- './volume3:/app'
# End HOW TODO this?
db:
image: mariadb
container_name: mariadb
ports:
- '3306:3306'
environment:
- MYSQL_ROOT_PASSWORD=toor
volumes:
- './db:/var/lib/mysql'
restart: always
pma:
image: phpmyadmin/phpmyadmin
container_name: pma
environment:
- PMA_ARBITRARY=1
- 'PMA_ABSOLUTE_URI=https://pma.local/'
- VIRTUAL_HOST=pma.local
restart: always
I've multiple app that needs to use composer, but I can't overwrite /app folder inside the composer container. 我有多个需要使用composer的应用程序,但无法覆盖composer容器内的/ app文件夹。 Should I write a Dockerfile inside each single app folder?
我是否应该在每个应用程序文件夹中编写一个Dockerfile? I don't want to specify the full path of PHP app inside the docker-compose, because I can have multiple version of an app (like 1.0, 2.0, ecc.ecc.).
我不想在docker-compose中指定PHP应用程序的完整路径,因为我可以拥有一个应用程序的多个版本(例如1.0、2.0,ecc.ecc)。
Instead of putting the Composer configuration in your Docker Compose file, you should probably just run it once for each PHP app before you run the system. 除了将Composer配置放入Docker Compose文件之外,您可能应该在运行系统之前为每个PHP应用程序运行一次 。
docker run --rm -v $(pwd)/volume1:/app composer:latest install
This will run composer and bind the directory to your host filesystem so that the vendor folder will be available. 这将运行composer并将目录绑定到您的主机文件系统,以便供应商文件夹可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.