|
1 | 1 | # Docker Kit |
2 | 2 |
|
3 | | -The humble kit with configuration files of Docker Compose for web development. Inside you can find the next configurations of virtual hosts: |
| 3 | +The humble kit with configuration files of Docker for a web development. Inside you can find simple web applications in JavaScript, Python and PHP. |
4 | 4 |
|
5 | | -#### Nginx |
6 | | -- Simple PHP web application |
7 | | -- WordPress |
8 | | -- Yii 2 (advanced application template) |
9 | | -- Yii 2 (basic application template) |
| 5 | +## Installation |
10 | 6 |
|
11 | | -#### Apache |
12 | | -- Yii 2 (advanced application template) |
| 7 | +Try it out by the following steps. |
13 | 8 |
|
14 | | -## Setup |
15 | | - |
16 | | -For example, set the kit to Ubuntu 16.04 x64 (with 512 MB RAM). You should add the swap space and install Docker Compose. |
17 | | - |
18 | | -1. Create and enable the swap file equal 2xRAM: |
19 | | -```bash |
20 | | -$ sudo fallocate -l 1G /swapfile |
21 | | -$ sudo chmod 600 /swapfile |
22 | | -$ sudo mkswap /swapfile |
23 | | -$ sudo swapon /swapfile |
24 | | -``` |
25 | | -2. Make the swap file permanent by adding it to the `/etc/fstab` file: |
26 | | -```bash |
27 | | -$ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab |
28 | | -``` |
29 | | -3. Modify kernel setting: |
30 | | -```bash |
31 | | -$ sudo sysctl vm.swappiness=10 |
32 | | -$ sudo sysctl vm.vfs_cache_pressure=50 |
33 | | -$ sudo sysctl vm.overcommit_memory=1 |
34 | | -$ sudo sysctl vm.overcommit_ratio=80 |
35 | | -``` |
36 | | -4. Set Docker memory limits: |
37 | | -```bash |
38 | | -$ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/default/grub |
39 | | -$ sudo update-grub |
40 | | -``` |
41 | | -5. Restart the system: |
42 | | -```bash |
43 | | -$ sudo shutdown -r now |
44 | | -``` |
45 | | -6. Install Docker and Docker Compose (by default `docker-compose.yml` is configured for nginx, you can change it): |
| 9 | +1. Download and install [Docker Engine](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/). |
| 10 | +> **Note:** Docker Compose should be install for all users into the `/usr/local/lib/docker/cli-plugins/docker-compose` directory. |
| 11 | +2. Clone the repository: |
46 | 12 | ```bash |
47 | | -$ curl -sSL get.docker.com -o docker-setup.sh |
48 | | -$ sh docker-setup.sh |
49 | | -$ rm docker-setup.sh |
50 | | -$ curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose |
51 | | -$ chmod +x /usr/local/bin/docker-compose |
| 13 | +$ cd /home/ |
| 14 | +$ git clone https://github.com/mickgeek/docker-kit.git |
52 | 15 | ``` |
53 | | -7. Clone the repository **into a directory with path `/srv/docker`**: |
| 16 | +3. Copy `.env.example` to `.env` and then edit the file according to needs: |
54 | 17 | ```bash |
55 | | -$ git clone https://github.com/mickgeek/docker-kit.git /srv/docker |
| 18 | +$ cp /home/docker-kit/docker/.env.example /home/docker-kit/docker/.env |
56 | 19 | ``` |
57 | | -8. Copy `.env.example` to `.env` and then edit the file according to needs: |
| 20 | +4. Start up the containers: |
58 | 21 | ```bash |
59 | | -$ cp /srv/docker/.env.example /srv/docker/.env |
| 22 | +$ cd /home/docker-kit/docker/ |
| 23 | +$ docker compose up |
60 | 24 | ``` |
61 | | -9. Add the service to system startup: |
| 25 | + |
| 26 | +## Tips |
| 27 | + |
| 28 | +### Service of the system startup |
| 29 | + |
| 30 | +To add the service to the system startup (Ubuntu 16.04), you should execute the next commands: |
62 | 31 | ```bash |
63 | | -$ cp /srv/docker/docker-compose-app.service /etc/systemd/system/ |
64 | | -$ sudo systemctl enable docker-compose-app |
65 | | -$ sudo systemctl start docker-compose-app |
| 32 | +$ cp /home/docker-kit/docker/docker-kit.service /etc/systemd/system/ |
| 33 | +$ sudo systemctl enable docker-kit |
| 34 | +$ sudo systemctl start docker-kit |
66 | 35 | ``` |
67 | | -10. For correct work of web server set necessary permissions via execute the `sudo chown -R www-data:www-data /srv/www` command. Use this directory for your projects 🍾 |
68 | 36 |
|
69 | | -> **Note:** To update Docker and Docker Compose you should delete both through the following commands: |
70 | | -> ```bash |
71 | | -> $ apt-get purge docker-ce |
72 | | -> $ rm /usr/local/bin/docker-compose |
73 | | -> ``` |
74 | | -> And then repeat the steps in point 5, specifying the desired version of Docker Compose. Also change `COMPOSE_API_VERSION` in the `.env` file according new API version of Docker (`$ docker version`). |
| 37 | +### Docker updating |
| 38 | + |
| 39 | +To update Docker Engine and Docker Compose you should delete both, and then install again specifying the desired version. Also change `DOCKER_API_VERSION` and `COMPOSE_API_VERSION` in the `.env` file according new API version of Docker Engine (`$ docker version`) and Docker Compose (`docker compose version`) respectively. |
| 40 | + |
| 41 | +### "Permission denied" error |
| 42 | + |
| 43 | +Use correct permissions for application directories. For PHP projects set permissions via execute the `sudo chown -R www-data:www-data /home/docker-kit/apps/php/` command. Or run the [docker-compose exec](https://docs.docker.com/compose/reference/exec/) command with the `--user` option. |
0 commit comments