Я попытался запустить под докером мое приложение laravel 5.5 / postgres 9, и в контейнере для композитора я получил ошибку:
Углерод 1 устарел, посмотрите, как перейти на Углерод 2. https://carbon.nesbot.com/docs/#api-carbon-2 Вы можете запустить './vendor/bin/upgrade-carbon', чтобы получить помощь в обновлении carbon и других фреймворков и библиотек, которые зависят от него.
Мой composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"barryvdh/laravel-debugbar": "^2.3",
"graham-campbell/markdown": "^8.0",
"intervention/image": "^2.3",
"khill/lavacharts": "3.0.*",
"laravel/framework": "5.5.*",
"laravel/socialite": "^3.0",
"laravel/tinker": "~1.0",
"laravelcollective/html": "^5.4.0",
"nwidart/laravel-modules": "^2.2",
"doctrine/dbal": "~2.5",
"wboyz/laravel-enum": "^0.2.1"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0",
"stolz/laravel-html-tidy": "^0.1.1",
"xethron/migrations-generator": "^2.0",
"filp/whoops" : "~2.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"Modules\\": "Modules/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
docker-compose.yml:
version: '3'
services:
web:
build:
context: ./web # directory of web/Dockerfile.yml
dockerfile: Dockerfile.yml
environment:
- APACHE_RUN_USER=#1000
container_name: lprods_web
volumes:
- ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
ports:
- 8086:80
working_dir: ${APP_PTH_CONTAINER}
db:
image: postgres:9.6.10-alpine
container_name: lprods_db
ports:
- '5433:5432'
restart: always
environment:
POSTGRES_USER: 'postgres'
POSTGRES_PASSWORD: '1'
POSTGRES_DB: 'wprods'
volumes:
- ./init:/docker-entrypoint-initdb.d/
adminer:
image: adminer
container_name: lprods_adminer
restart: always
ports:
- 8087:80
links:
- db
composer:
image: composer:1.6
container_name: lprods_composer
volumes:
- ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
working_dir: ${APP_PTH_CONTAINER}
command: composer install --ignore-platform-reqs
и web / Dockerfile.yml:
FROM php:7.1-apache
RUN apt-get update && \
apt-get install -y \
python \
libfreetype6-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
nano \
git-core \
curl \
build-essential \
openssl \
libssl-dev \
libgmp-dev \
libldap2-dev \
libpq-dev \
netcat \
sqlite3 \
libsqlite3-dev \
&& git clone https://github.com/nodejs/node.git \
&& cd node \
&& git checkout v12.0.0 \
&& ./configure \
&& make \
&& make install
RUN npm install cross-env
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install gd pgsql pdo_pgsql zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf
Я не уверен, какие шаги я должен предпринять? Добавить команду
RUN ./vendor/bin/upgrade-carbon
В конец файла web / Dockerfile.yml?
ИЗМЕНЕНО: При входе в Docker Bash Я попытался запустить предложенную команду, но получил ошибку:
$ docker-compose exec web bash
root@863c9aa86d25:/var/www/lprods_docker_root# php -v
PHP 7.1.33 (cli) (built: Oct 25 2019 06:33:10) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
root@863c9aa86d25:/var/www/lprods_docker_root# ./vendor/bin/upgrade-carbon
sh: 1: composer: not found
Fatal error: Uncaught Error: Class 'Composer\Composer' not found in /var/www/lprods_docker_root/vendor/nesbot/carbon/src/Carbon/Upgrade.php:131
Stack trace:
#0 /var/www/lprods_docker_root/vendor/nesbot/carbon/bin/upgrade-carbon(28): Carbon\Upgrade::upgrade()
#1 {main}
thrown in /var/www/lprods_docker_root/vendor/nesbot/carbon/src/Carbon/Upgrade.php on line 131
?
ИЗМЕНЕНО #2: Я попытался добавить предложенную команду upgrade-carbon в файл web / Dockerfile.yml:
RUN docker-php-ext-install gd pgsql pdo_pgsql zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
RUN ./vendor/bin/upgrade-carbon
COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf
Но я получил ошибку:
Step 5/7 : RUN docker-php-ext-install gd pgsql pdo_pgsql zip gmp bcmath pcntl ldap sysvmsg exif && a2enmod rewrite
---> Using cache
---> 60c29909c34a
Step 6/7 : RUN ./vendor/bin/upgrade-carbon
---> Running in 4fb9274ac5cb
/bin/sh: 1: ./vendor/bin/upgrade-carbon: not found
ERROR: Service 'web' failed to build: The command '/bin/sh -c ./vendor/bin/upgrade-carbon' returned a non-zero code: 127
Полагаю, мне нужнозапустить команду upgrade-carbon ПОСЛЕ команды в файле композитора:
command: composer install --ignore-platform-reqs
Можно ли это сделать в докере и как?
Спасибо!