harbor run -t LiteCoder/containerize-legacy-php-lampharbor download LiteCoder/containerize-legacy-php-lampContainerize a legacy PHP/MySQL application into a Dockerized LAMP stack using Docker Compose, with persistent data, secure credentials, and automated database seeding.
/app/Create the following directory layout:
/app/
docker-compose.yml
.env
Makefile
php/
Dockerfile
src/
index.php
mysql/
init/
seed.sql
.envMust define exactly these variables (values are your choice but must be non-empty):
MYSQL_ROOT_PASSWORDMYSQL_DATABASEMYSQL_USERMYSQL_PASSWORDphp/Dockerfilephp:5.6-apachemysqli, gd, mcrypt, zip/var/www/htmlsrc/ directorysrc/index.phpCreate a minimal PHP page that:
MYSQL_DATABASE, MYSQL_USER, MYSQL_PASSWORD)db on port 3306 using mysqlicampaigns table with SELECT * FROM campaignsError.mysql/init/seed.sqlCreate a SQL seed script that:
campaigns with columns:
id INT AUTO_INCREMENT PRIMARY KEYname VARCHAR(255) NOT NULLstatus VARCHAR(50) NOT NULLcreated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP'Summer Sale', 'active')'Winter Promo', 'paused')'Spring Launch', 'draft')docker-compose.ymlMust define exactly two services:
Service web:
./php/./src to /var/www/html in the container8080 to container port 80.env file using env_filedb servicerestart: unless-stoppedService db:
mysql:5.7.env file using env_filemysql_data mounted at /var/lib/mysql./mysql/init/ to /docker-entrypoint-initdb.d/ for automatic seed execution on first launchmysqladmin ping -h localhost with interval 10s, timeout 5s, and 5 retriesVolumes section:
mysql_dataMakefileMust include these targets:
build : runs docker-compose buildup : runs docker-compose up -ddown : runs docker-compose downlogs : runs docker-compose logs -fdestroy : runs docker-compose down -v