Skip to content

๐Ÿ— Docker with Apache - PHP - MySQL - PhpMyAdmin - Mailhog | development environment

License

Notifications You must be signed in to change notification settings

prod3v3loper/docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

48 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PHP 8 development environment

With Apache - PHP - MySQL - PhpMyAdmin - Mailhog

localhost phpmyadmin mailhog
Server Database Email
http://localhost:8002 http://localhost:8003 http://localhost:7025

You need to have Docker installed on your server to proceed using this PHP environment.

Donwload Docker: https://www.docker.com/

The following four separate service containers will be used:

  • php service running PHP 8. (Created from Dockerfile)

  • apache service running Apache2. (Created from Dockerfile)

  • db service running MySQL. (Created from Image)

  • phpmyadmin service running PhpMyAdmin. (Created from Image)

  • mailhog service running Mailhog. (Created from Dockerfile and Image)

Setting up

Get the project per git or donwload it from github https://github.com/prod3v3loper/docker/releases.

$ git clone https://github.com/prod3v3loper/docker.git

Before you start for the first time

Set the MySQL environment variables creating a .env file, with:

/* Default dont touch is defined in docker-compose.yml */
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306

/* Use what you want here */
DB_DATABASE=databasename
DB_USERNAME=username
DB_PASSWORD=password

Running the environment

When the build is finished, you can run the environment in background mode with:

$ docker-compose up -d

Start with when mysql or other not running to log the states:

$ docker-compose up

Rebuild to recreate the images and settings on startup:

$ docker-compose up -d --no-deps --build

Recreate the db on startup:

$ docker-compose up --force-recreate db

To shut down your Docker Compose environment and remove all of its containers, networks, and volumes, run:

$ docker-compose down

Now go to your browser and access your serverโ€™s domain name or IP address on port 8002.

localhost phpmyadmin mailhog
Server machine PhpMyAdmin storage Mail testing
http://localhost:8002 http://localhost:8003 http://localhost:7025

Defined in docker-compose.yml

Useful commands

Docker

To show information about the state of your active services (e.g. CONTAINER-ID), run:

$ docker ps

If the container is running but not showing up with just docker ps, extend it with the -a parameter:

$ docker ps -a

Go direct in the container per bash:

$ docker exec -it <CONTAINER-ID OR NAME> bash

Root

Inside the container you can run PHP

$ php -m

Or run composer

$ composer install 

More

If you not in a bash environment, get bash in this project and run:

$ docker exec -it <CONTAINER-ID OR NAME> /bin/bash

Copy files from container

$ docker cp <CONTAINER-ID OR NAME>:/usr/local/etc/php php

You can use the docker exec command to execute commands in the service containers, without going into the container:

$ docker exec <CONTAINER-ID OR NAME> ls -l
$ docker exec <CONTAINER-ID OR NAME> composer install
$ docker exec <CONTAINER-ID OR NAME> php -m

Build the app image to upload in dockerhub:

$ docker build <CONTAINER-ID OR NAME>

Test

Call the URLs to test database and mail.

Database Email
Check after that in phpmyadmin Check after that mailhog
http://localhost:8002/dbtest/ http://localhost:8002/mailtest/

ISSUE

Please use the issue tab to request a:

  • Bug
  • Feature

Choose template and report a bug or feature you want issues.

CONTRIBUTE

Please read the contributing to contribute.

VULNERABILITY

Please use the Security section for privately reporting a vulnerability.

Authors

PROD3V3LOPER - All works

License

MIT

Releases

No releases published

Packages

No packages published