Я пытаюсь запустить проект Laravel Docker на AWS Fargate.
Проект создается и успешно запускается на локальном компьютере. Я могу перейти к http: // локальный: 8000 и он отлично работает.
Однако, когда я пытаюсь запустить проект на экземпляре AWS Fargate или EC2 с запущенным докером, я получаю ошибки. Чтобы воспроизвести проблему, проверьте 2 сценария ниже.
Вот мои файлы конфигурации.
Dockerfile
FROM nginx:mainline-alpine
COPY start.sh /start.sh
COPY nginx.conf /etc/nginx/nginx.conf
COPY supervisord.conf /etc/supervisord.conf
COPY site.conf /etc/nginx/sites-available/default.conf
RUN apk add --update \
php7 \
php7-fpm \
php7-pdo \
php7-pdo_mysql \
php7-mcrypt \
php7-mbstring \
php7-xml \
php7-openssl \
php7-json \
php7-phar \
php7-zip \
php7-dom \
php7-session \
php7-zlib && \
php7 -r "copy('http://getcomposer.org/installer', 'composer-setup.php');" && \
php7 composer-setup.php --install-dir=/usr/bin --filename=composer && \
php7 -r "unlink('composer-setup.php');" && \
ln -s -f /usr/bin/php7 /usr/bin/php && \
ln -s -f /etc/php7/php.ini /etc/php7/conf.d/php.ini
RUN apk add --update \
bash \
openssh-client \
supervisor
RUN mkdir -p /etc/nginx && \
mkdir -p /etc/nginx/sites-available && \
mkdir -p /etc/nginx/sites-enabled && \
mkdir -p /run/nginx && \
ln -s /etc/nginx/sites-available/default.conf /etc/nginx/sites-enabled/default.conf && \
mkdir -p /var/log/supervisor && \
rm -Rf /var/www/* && \
chmod 755 /start.sh
RUN sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" \
-e "s/variables_order = \"GPCS\"/variables_order = \"EGPCS\"/g" \
/etc/php7/php.ini && \
sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" \
-e "s/;catch_workers_output\s*=\s*yes/catch_workers_output = yes/g" \
-e "s/user = nobody/user = nginx/g" \
-e "s/group = nobody/group = nginx/g" \
-e "s/;listen.mode = 0660/listen.mode = 0666/g" \
-e "s/;listen.owner = nobody/listen.owner = nginx/g" \
-e "s/;listen.group = nobody/listen.group = nginx/g" \
-e "s/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm.sock/g" \
-e "s/^;clear_env = no$/clear_env = no/" \
/etc/php7/php-fpm.d/www.conf
EXPOSE 443 80
COPY . /var/www
WORKDIR /var/www
RUN chmod -R 777 storage/
RUN echo `ls`
CMD ["/start.sh"]
start.sh
#!/bin/bash
# ----------------------------------------------------------------------
# Create the .env file if it does not exist.
# ----------------------------------------------------------------------
if [[ ! -f "/var/www/.env" ]] && [[ -f "/var/www/.env.example" ]];
then
cp /var/www/.env.example /var/www/.env
fi
# ----------------------------------------------------------------------
# Run Composer
# ----------------------------------------------------------------------
if [[ ! -d "/var/www/vendor" ]];
then
cd /var/www
composer install
composer dump-autoload -o
fi
# ----------------------------------------------------------------------
# Start supervisord
# ----------------------------------------------------------------------
exec /usr/bin/supervisord -n -c /etc/supervisord.conf
supervisord.conf
[unix_http_server]
file=/dev/shm/supervisor.sock
[supervisord]
logfile=/tmp/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=warn
pidfile=/tmp/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
user=root
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///dev/shm/supervisor.sock
[program:php-fpm7]
command = /usr/sbin/php-fpm7 --nodaemonize --fpm-config /etc/php7/php-fpm.d/www.conf
autostart=true
autorestart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
autostart=true
autorestart=true
priority=10
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log off;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/sites-enabled/*.conf;
}
site.conf
server {
listen 80;
root /var/www/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ /\. {
deny all;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
И это вывод журналов докеров
docker logs $(docker ps -a -q)
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for league/flysystem 1.0.49 -> satisfiable by league/flysystem[1.0.49].
- league/flysystem 1.0.49 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
Problem 2
- Installation request for phpunit/php-code-coverage 6.1.4 -> satisfiable by phpunit/php-code-coverage[6.1.4].
- phpunit/php-code-coverage 6.1.4 requires ext-xmlwriter * -> the requested PHP extension xmlwriter is missing from your system.
Problem 3
- Installation request for phpunit/php-token-stream 3.0.1 -> satisfiable by phpunit/php-token-stream[3.0.1].
- phpunit/php-token-stream 3.0.1 requires ext-tokenizer * -> the requested PHP extension tokenizer is missing from your system.
Problem 4
- Installation request for theseer/tokenizer 1.1.0 -> satisfiable by theseer/tokenizer[1.1.0].
- theseer/tokenizer 1.1.0 requires ext-tokenizer * -> the requested PHP extension tokenizer is missing from your system.
Problem 5
- league/flysystem 1.0.49 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
- laravelista/lumen-vendor-publish 2.1.0 requires league/flysystem ^1.0 -> satisfiable by league/flysystem[1.0.49].
- Installation request for laravelista/lumen-vendor-publish 2.1.0 -> satisfiable by laravelista/lumen-vendor-publish[2.1.0].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php7/php.ini
- /etc/php7/conf.d/00_dom.ini
- /etc/php7/conf.d/00_json.ini
- /etc/php7/conf.d/00_mbstring.ini
- /etc/php7/conf.d/00_openssl.ini
- /etc/php7/conf.d/00_pdo.ini
- /etc/php7/conf.d/00_session.ini
- /etc/php7/conf.d/00_xml.ini
- /etc/php7/conf.d/00_zip.ini
- /etc/php7/conf.d/01_mysqlnd.ini
- /etc/php7/conf.d/01_phar.ini
- /etc/php7/conf.d/02_pdo_mysql.ini
- /etc/php7/conf.d/mcrypt.ini
- /etc/php7/conf.d/php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Generated optimized autoload files containing 80 classes
2019-02-10 13:40:56,816 CRIT Server 'unix_http_server' running without any HTTP authentication checking
composer.json
{
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": ["framework", "laravel", "lumen"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.1.3",
"firebase/php-jwt": "^5.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/lumen-framework": "5.7.*",
"laravelista/lumen-vendor-publish": "^2.1",
"proshore/entrust-lumen": "1.0.2",
"spatie/laravel-searchable": "^1.2",
"vlucas/phpdotenv": "~2.2"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"phpunit/phpunit": "~7.0",
"mockery/mockery": "~1.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/"
]
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}