version: ‘3.4’
services:
mysql:
image: msql: 5.7
restart: unless-stopped
tty: true
ports:
– ‘803306:3306’
volumes:
- type: volume
source: ./mysql
target: /var/lib/mysql
environment:
MYSQL_DATABASE: root
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
SERVICE_TAGS: dev
SERVICE_NAME: mysql
php:
build:
context: .
dockerfile: dockerfile
container_name: php
volumes:
- type: volume
source: ./src
target: /var/www/html
working_dir: /var/www/html
command: php artisan serve –host=0.0.0.0 –port=8000
ports:
-‘808000:8000’
dockerfile
FROM php: 7.4-apache
COPY SRC/ /var/www/html
RUN pecl install xdebug && docker-php-ext-enable xdebug && docker-php-ext-install pdo_mysql
docker commands
docker-compose up -d
docker-compose ps
docker-compose stop
docker image ls
additions
Edit the .env file provided
Enable migration and seeding with docker-compose exec
Notice that To be able to migrate you need to type the command
docker-compose exec php php var/www/html/artisan migrate