Skip to content

Commit eff8345

Browse files
committed
Python container adding
1 parent 1eb3004 commit eff8345

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+355
-568
lines changed

README.md

Lines changed: 29 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,43 @@
11
# Docker Kit
22

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

5-
#### Nginx
6-
- Simple PHP web application
7-
- WordPress
8-
- Yii 2 (advanced application template)
9-
- Yii 2 (basic application template)
5+
## Installation
106

11-
#### Apache
12-
- Yii 2 (advanced application template)
7+
Try it out by the following steps.
138

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:
4612
```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
5215
```
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:
5417
```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
5619
```
57-
8. Copy `.env.example` to `.env` and then edit the file according to needs:
20+
4. Start up the containers:
5821
```bash
59-
$ cp /srv/docker/.env.example /srv/docker/.env
22+
$ cd /home/docker-kit/docker/
23+
$ docker compose up
6024
```
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:
6231
```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
6635
```
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 🍾
6836

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.

apache/vhosts/yii2advanced.conf

Lines changed: 0 additions & 19 deletions
This file was deleted.

apps/js/app.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const http = require('http');
2+
3+
const hostname = '0.0.0.0';
4+
const port = 3000;
5+
6+
const server = http.createServer((req, res) => {
7+
res.statusCode = 200;
8+
res.setHeader('Content-Type', 'text/plain');
9+
res.end('It works! Your JavaScript application can grow up.');
10+
});
11+
12+
server.listen(port, hostname, () => {
13+
console.log(`Server running at http://${hostname}:${port}/`);
14+
});

apps/php/app.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
echo 'It works! Your PHP application can grow up.';

apps/py/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/bin
2+
/include
3+
/lib
4+
/lib64
5+
/pyvenv.cfg

apps/py/app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from werkzeug.serving import run_simple
4+
from werkzeug.wrappers import Response
5+
6+
def create_app():
7+
return Response('It works! Your Python application can grow up.')
8+
9+
if __name__ == '__main__':
10+
app = create_app()
11+
run_simple('0.0.0.0', 5000, app, use_debugger=True, use_reloader=True)

apps/py/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Werkzeug

docker-compose-app.service

Lines changed: 0 additions & 16 deletions
This file was deleted.

docker-compose.yml

Lines changed: 0 additions & 136 deletions
This file was deleted.
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
COMPOSE_API_VERSION=1.39
1+
DOCKER_API_VERSION=1.41
2+
COMPOSE_API_VERSION=2.2.3
23

34
TZ=Europe/Moscow
45

56
PHP_OPCACHE_ENABLE=1
6-
PHP_XDEBUG_ENABLE=1
7-
PHP_XDEBUG_REMOTE_HOST=10.0.2.2
8-
PHP_XDEBUG_IDEKEY=xdebug-atom
7+
8+
PHP_XDEBUG_MODE=develop
9+
PHP_XDEBUG_CLIENT_HOST=0.0.0.0
10+
PHP_XDEBUG_IDEKEY=xdebug-ide
911

1012
# https://github.com/settings/tokens/new?scopes=repo&description=Docker+Composer
1113
GITHUB_OAUTH_TOKEN=0000000000000000000000000000000000000000
1214

13-
DB_NAME=app
14-
DB_USER=root
15-
DB_PASSWORD=root
16-
17-
MYSQL_ROOT_PASSWORD=root
15+
POSTGRES_DB=app
16+
POSTGRES_USER=root
17+
POSTGRES_PASSWORD=root
1818

19-
MYSQL_ROOT_HOST=%
2019
REDIS_PASSWORD=root

0 commit comments

Comments
 (0)