I want to use Docker with APACHE, PHP, MYSQL projects with files structure like in Laravel where there is a 'public' folder with a public files and all of the apps files are one level higher in.ex. app, modules, node, vendor etc. I can setup docker-compose.yml file and Dockerfile to create docker container with APACHE-PHP, MYSQL and PHPMYADMIN and it's working but all of files one level higher that WORKDIR is unavailable.
My problem is I can't setup this container to properly use my app. Simple PHP script below is not working. What should I do?
[public/index.php]
<?php
echo "index.php";
require_once __DIR__ . "/../include.php";
[docker-compose.yml]
version: '3.9'
services:
php-env:
build: .
volumes:
- ./public:/var/www/html
ports:
- 8000:80
mysql-db:
image: mysql:latest
ports:
- 3306:3306
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASS}
MYSQL_ROOT_PASSWORD: ${DB_PASS}
[Dockerfile]
FROM php:8.1-apache
WORKDIR /var/www/html
RUN apt-get update -y && apt-get install -y libmariadb-dev
RUN docker-php-ext-install mysqli