Go to file
Adrien Marquès d38ef34eb7 include TOC 2018-09-26 16:29:28 +02:00
virtual min update 2018-09-26 16:26:56 +02:00
.gitignore add .gitignore to ignore /var/logs and /var/lib/mysql 2018-09-26 16:24:05 +02:00
LICENSE update licence credentials 2018-09-26 13:56:29 +02:00
README.md include TOC 2018-09-26 16:29:28 +02:00
docker-compose.yml setup 'php-fpm' dockerfile to install extension PDO 2018-09-26 15:06:44 +02:00
php-fpm.dockerfile setup 'php-fpm' dockerfile to install extension PDO 2018-09-26 15:06:44 +02:00

README.md

| Introduction to docker (2) |

Table Of Contents

III. Setting up a development stack

1) Choosing images

We will setup a simple web dev stack with :

  • nginx (i.e. nginx:latest)
  • mariadb (i.e. mariadb:latest)
  • php-fpm (i.e. php:7-fpm)

2) Volume & network sharing policy

1. Volume sharing

a) Configuration files

The apache and php configuration will be on the host machine (for easy modification) and only mounted on the containers to override the default configuration files. A virtual folder will hold these configurations with the same path for consistency:

b) Storage files

MariaDB will have its whole data folder (i.e. /var/lib/mysql) on the host in the virtual folder to have the data remaining throughout containers. This property makes the database consistent and persistent among container creation/deletion.

In a real-world environment, we would not store the whole data folder (in fact it would be in the .gitignore), but we would add a script to dump a SQL file into the database when using the environment for the first time :

cat backup.sql | docker exec -i mariadb mysql -uroot -p

> Then, the volumes would be shared and persistent on the host.





###### 	c) Log files

Also logs will be mounted the same way in order for developers to easily check these out when needed (_e.g. `virtual/var/log/apache2/access.log`_). Also, note that even if the container is removed, the logs will remain.



######  d) Development folder

The development folder (_i.e. the actual code to test_) is located in the folder [virtual/vhost](./virtual/vhost). In a real-world use of this configuration, I would clone a git repository into it in order for my docker configuration and my actual code not to mix together ; we could then use _git submodules_ for version stability among the 2 repositories.



#### 2. Network sharing



###### a) Ports and network

The whole system will only expose its port `8080` ;

> We do not use the default HTTP port not to break a possible web server on the host.

Containers between them will be connected through the `privnet` network which is also reachable from the host ; except for the port 8080.



###### b) DNS

The `nginx` container is configured to only accept the host `somedomain.io`, it corresponds to the DNS record chosen for the production server. This domain must be added into the `/etc/hosts` file of each developer in order for them to access the web server at `somedomain.io:8080`.



###### c) Production deployment

If the project is pushed into a production server, if you have no other program occupying the port `80`, you can just replace the port binding `8080:80` in `docker-compose.yml`. If it is already taken by apache/nginx, you will have to create an entry in your web server to forward your requests from your address (_i.e. domain.com_) to the specific port 8080 (_c.f. [reverse proxy](https://en.wikipedia.org/wiki/Reverse_proxy)_).



### 3) Launch the environment



#### 1. Download the sources

```bash
git clone https://git.xdrm.io/MTI/tp-docker-eisti ./tp-adrien-marques;

2. Launch it

It is now fairly simple just run the 2 following commands (inside the repository) :

docker-compose up; # launch the env
xdg-open "http://somedomain.io:8080"; # open the web page

Notes:

  • when restarting the environment, the database persists.