Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/prod3v3loper/docker

πŸ— Docker with Apache - PHP - MySQL - PhpMyAdmin - Mailhog | development environment
https://github.com/prod3v3loper/docker

apache development development-environment docker docker-compose docker-container dockerfile dump environment mailhog mysql mysql-database php php8 phpmyadmin

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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.

```bash
$ 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:

```js
/* 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:
```bash
$ docker-compose up -d
```

Start with when mysql or other not running to log the states:
```bash
$ docker-compose up
```

Rebuild to recreate the images and settings on startup:
```bash
$ docker-compose up -d --no-deps --build
```

Recreate the db on startup:
```bash
$ docker-compose up --force-recreate db
```

To shut down your Docker Compose environment and remove all of its containers, networks, and volumes, run:
```bash
$ 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:
```bash
$ docker ps
```

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

Go direct in the container per bash:
```bash
$ docker exec -it bash
```

### Root

Inside the container you can run PHP
```bash
$ php -m
```

Or run composer
```bash
$ composer install
```

### More

If you not in a bash environment, get bash in this project and run:
```bash
$ docker exec -it /bin/bash
```

Copy files from container
```bash
$ docker cp :/usr/local/etc/php php
```

You can use the docker exec command to execute commands in the service containers, without going into the container:
```bash
$ docker exec ls -l
```

```bash
$ docker exec composer install
```

```bash
$ docker exec php -m
```

Build the app image to upload in dockerhub:
```bash
$ docker build
```

# 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](https://github.com/prod3v3loper/docker/issues).

# CONTRIBUTE

Please read the [contributing](https://github.com/prod3v3loper/docker/blob/master/.github/CONTRIBUTING.md) to contribute.

# VULNERABILITY

Please use the Security section for privately reporting a [vulnerability](https://github.com/prod3v3loper/docker/security).

# Authors

**[PROD3V3LOPER](https://www.prod3v3loper.com)** - _All works_

# License

[MIT](https://github.com/prod3v3loper/docker/blob/master/LICENSE)