Skip to content

Docker container running Apache running on Ubuntu, Composer, Lavavel, TDD via Shippable & CircleCI

Notifications You must be signed in to change notification settings

UbuntuEvangelist/Apache

 
 

Repository files navigation

Apache Docker

Run Status Circle CI Beerpay Beerpay

This repo will give you a turn key Docker container build for use in production OR dev. The setup includes an Apache web service, PHP 7.3, PHP Composer, linked MySQL 5.7.28 instance and a data container volume.

Using containers offer a huge advantage when developing locally or in prodcution. Use this containers for development and deployment. Changing NODE_ENVIRONMENT within to .env to dev or production will offer a dynamic environment.

Listed below is an explanation of each file. Ask a question!

Dependencies


Build Breakdown

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/
│   └── config.yml           # → CircleCI 2.0 Config
├── docker-compose.local.yml # → Dev 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

Quick Start

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

Mac OS X / Linux

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 

(non Make Windows)

> copy .env.example .env
> docker-compose -f docker-compose.local.yml up -d

phpMyAdmin

Review MySQL access instructions upon make run command execution. Setup phpMyAdmin directly via command line. https://localhost:8080

> docker run --name myadmin -d --link apache_db:db --net apache_default -p 8080:80 phpmyadmin/phpmyadmin

Login using the following creditial stored within the .env file:

username password
root $MYSQL_ROOT_PASSWORD
$MYSQL_PASSWORD $MYSQL_PASSWORD

Test Driven Development

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.

Interacting with Containers:

List all running containers:

docker ps

List all containers (including stopped containers):

docker ps -a

Review og 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]

Teardown

(Stop all running containers started by Docker Compose):

Mac OS X / Linux

> make rm 

(non Make Windows)

> docker-compose stop

About

Docker container running Apache running on Ubuntu, Composer, Lavavel, TDD via Shippable & CircleCI

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 52.0%
  • PHP 18.5%
  • Dockerfile 17.7%
  • Makefile 11.8%