I tried to have a very minimal setup, to dockerize Laravel app. Even the nginx able to forward the request to Laravel container, I'm still getting GET /index.php" 404
C:\yocto\snapweb>docker-compose logs --follow laravel
Attaching to snapweb_laravel_1
laravel_1 | [23-Jul-2018 07:10:04] NOTICE: fpm is running, pid 1
laravel_1 | [23-Jul-2018 07:10:04] NOTICE: ready to handle connections
laravel_1 | 172.18.0.3 - 23/Jul/2018:07:14:01 +0000 "GET /index.php" 404
When I went inside laravel container, this is how it looks like. Seem fine to me.
Inside Laravel container
/var/www/html # pwd
/var/www/html
/var/www/html # ls -al
total 224
drwxr-xr-x 1 root root 4096 Jul 23 07:09 .
drwxr-xr-x 1 root root 4096 Jul 21 08:11 ..
-rwxr-xr-x 1 root root 668 Jul 23 07:08 Dockerfile
drwxr-xr-x 6 root root 4096 May 8 19:42 app
-rwxr-xr-x 1 root root 1686 May 8 19:42 artisan
drwxr-xr-x 3 root root 4096 May 8 19:42 bootstrap
-rw-r--r-- 1 root root 1477 May 8 19:42 composer.json
-rw-r--r-- 1 root root 144199 Jul 23 07:03 composer.lock
drwxr-xr-x 2 root root 4096 May 8 19:42 config
drwxr-xr-x 5 root root 4096 May 8 19:42 database
-rw-r--r-- 1 root root 1022 May 8 19:42 package.json
-rw-r--r-- 1 root root 1134 May 8 19:42 phpunit.xml
drwxr-xr-x 4 root root 4096 May 8 19:42 public
-rw-r--r-- 1 root root 3675 May 8 19:42 readme.md
drwxr-xr-x 5 root root 4096 May 8 19:42 resources
drwxr-xr-x 2 root root 4096 May 8 19:42 routes
-rw-r--r-- 1 root root 563 May 8 19:42 server.php
drwxr-xr-x 5 root root 4096 May 8 19:42 storage
drwxr-xr-x 4 root root 4096 May 8 19:42 tests
drwxr-xr-x 37 root root 4096 Jul 23 07:03 vendor
-rw-r--r-- 1 root root 549 May 8 19:42 webpack.mix.js
/var/www/html # ls -al public
total 32
drwxr-xr-x 4 root root 4096 May 8 19:42 .
drwxr-xr-x 1 root root 4096 Jul 23 07:09 ..
-rw-r--r-- 1 root root 593 May 8 19:42 .htaccess
drwxr-xr-x 2 root root 4096 May 8 19:42 css
-rw-r--r-- 1 root root 0 May 8 19:42 favicon.ico
-rw-r--r-- 1 root root 1823 May 8 19:42 index.php
drwxr-xr-x 2 root root 4096 May 8 19:42 js
-rw-r--r-- 1 root root 24 May 8 19:42 robots.txt
-rw-r--r-- 1 root root 914 May 8 19:42 web.config
/var/www/html #
May I know what's wrong with my setup? Here's my minimalist Dockerfiles
laravel/Dockerfile
FROM php:7.2.8-fpm-alpine3.7
RUN apk update && \
apk add git && \
apk add unzip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Get laravel into a temporary folder.
RUN composer create-project --prefer-dist laravel/laravel laravel-install-tmp
# Move local host files to docker container.
COPY . /var/www/html
# Copy all laravel files, without overwrite files from host.
RUN false | cp -ai /var/www/html/laravel-install-tmp/* /var/www/html/ 2>/dev/null
# Remove temporary folder.
RUN rm -rf /var/www/html/laravel-install-tmp/
WORKDIR /var/www/html
CMD ["php-fpm", "-F"]
nginx/default.conf
server {
listen 443;
ssl on;
ssl_certificate /app/cert.pem;
ssl_certificate_key /app/key.pem;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass laravel:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
nginx/Dockerfile
FROM nginx:1.13.9-alpine
COPY . /app
RUN rm /etc/nginx/conf.d/default.conf
COPY default.conf /etc/nginx/conf.d/
docker-compose.yml
version: '2'
services:
# Note, SSL cert (cert.pem and key.pem) is generated from cloudflare.
nginx:
build:
context: ./nginx
dockerfile: Dockerfile
restart: always
ports:
- "2053:443"
laravel:
build:
context: ./laravel
dockerfile: Dockerfile
restart: always