This repo will give you a turn key Docker container build for use in production OR local development. The setup includes an Apache web service, PHP 7.3, PHP Composer, linked MySQL 5.7.26 instance and a data container volume.
In this repo you will find a number of complete Dockerfile builds used in development and production environments. Listed below is an explanation of each file. Ask a question!
Apache # → Root of Docker Build
├── app/ # → App conf to manage application on container
│ ├── apache-config.conf # → Default Apache config
│ ├── index.php # → Default web page, enter the IP `docker-machine ls` to load this page.
│ ├── mac-permissions.sh # → Run manually on container to match uid / gid permissions of local docker container to Mac OS X
│ ├── postfix.sh # → Used by *supervisord.conf* to start Postfix
│ ├── run.sh # → Setup apache, conf files, and start process on container
│ ├── sample.conf # → located within `/data/apache2/sites-enabled` duplicate / modify to host others domains
│ └── supervisord # → Supervisor is a client / server system which monitors and controls a number of processes on UNIX-like operating systems
├── .env.example # → Rename file to `.env` for local environment variables used within build
├── .circleci/ # → CircleCI 2.0
│ └── config.yml # → CircleCI Config
├── docker-compose.local.yml # → Local build
├── docker-compose.yml # → Production build
├── Dockerfile # → Uses a basefile build to help speed up the docker container build process
├── Makefile # → Build command shortcuts
├── shippable.yml # → Configuration for Shippable.com testing
└── tests/
└── build_tests.sh # → Build test processes
Docker Compose YML configuration guide more info
Launch the Apache instance locally and setup a local MySQL database container for persistant database data, the goal is to create a easy to use development environment.
The Apache container the directory /data
is shared to your local system via Line 7 within docker-container.local.yml
file
Type
make
for more build options:
$ git clone https://github.com/htmlgraphic/Apache.git ~/Docker/Apache && cd ~/Docker/Apache
$ cp .env.example .env
$ make run
OR (non Make Windows)
$ copy .env.example .env
$ docker-compose -f docker-compose.local.yml up -d
Review MySQL access instructions upon make run
command execution. Setup phpMyAdmin directly via command line.
$ docker run --name myadmin -d --link apache_db:db --net apache_default -p 8080:80 phpmyadmin/phpmyadmin
LOCAL: https://localhost:8080
Login using the following creditial stored within the .env file:
username | password |
---|---|
root | $new_passwordac |
$MYSQL_PASSWORD | $MYSQL_PASSWORD |
These continuous integration services will fully test the creation of your container and can push the complete image to your private Docker repo if you desire.
CircleCI 2.0 - Test production and dev Docker builds, can the container be built the without error? Verify each build process using docker-compose. Code can be tested using lxc-attach / docker inspect
inside the running container
Shippable - Test production and dev Docker builds, can the container be built the without error? The /tests/build_tests.sh
file ensures the can run with parameters defined. Shippable allows the use of matrix environment variables reducing build time and offer a more robust tests. If any test(s) fail the system should be reviewed closer.
List all running containers:
docker ps
List all containers (including stopped containers):
docker ps -a
Read the log of a running container:
docker logs [CONTAINER ID OR NAME]
Follow the log of a running container:
docker logs -f [CONTAINER ID OR NAME]
Read the Apache log:
docker exec [CONTAINER ID OR NAME] cat ./data/apache2/logs/access_log
Follow the Apache log:
docker exec [CONTAINER ID OR NAME] tail -f ./data/apache2/logs/access_log
Follow the outgoing mail log:
docker exec [CONTAINER ID OR NAME] tail -f ./var/log/mail.log
Gain terminal access to a running container:
docker exec -it [CONTAINER ID OR NAME] /bin/bash
Restart a running container:
docker restart [CONTAINER ID OR NAME]
Stop and start a container in separate operations:
docker stop [CONTAINER ID OR NAME]
docker start [CONTAINER ID OR NAME]
$ make rm
OR (non Make Windows)
$ docker rm -f apache_web && docker rm -f apache_db