Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Update TD
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibaut-gauvin committed Sep 27, 2017
1 parent a5827fb commit 6916e27
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 28 deletions.
1 change: 1 addition & 0 deletions 01-dockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM nginx
# FROM nginx:1.12

COPY index.html /usr/share/nginx/html

Expand Down
4 changes: 1 addition & 3 deletions 02-volumes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

$PWD return the absolute path to your current directory, test in your terminal:

echo $PWD
echo $PWD (Print Working Directory)
/home/thibaut/meetup_docker_101/02-volumes


Expand All @@ -28,6 +28,4 @@ $PWD return the absolute path to your current directory, test in your terminal:
root@51aafa93a21e:/home/docker# ls -alh
drwxrwxr-x 2 1000 1000 4.0K Sep 25 20:25 .
drwxr-xr-x 3 root root 4.0K Sep 25 20:16 ..
-rw-rw-r-- 1 1000 1000 492 Sep 25 20:25 README.md
-rw-rw-r-- 1 1000 1000 123 Sep 25 20:15 nginx.conf
-rw-rw-r-- 1 1000 1000 113 Sep 22 19:31 toto.html
1 change: 1 addition & 0 deletions 02-volumes/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
server {
listen 80;

root /home/docker;

index toto.html;
Expand Down
2 changes: 1 addition & 1 deletion 02-volumes/toto.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<title>hello world</title>
</head>
<body>
<p>hello world !</p>
<p>hello world from toto.html</p>
</body>
</html>
7 changes: 3 additions & 4 deletions 03-link-container/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ example with nginx + php7.1-fpm
docker network create demo_meetup


### Star PHP container :
### Start PHP container :

docker run -d \
--name php \
Expand All @@ -24,11 +24,10 @@ example with nginx + php7.1-fpm

docker run -d \
--name web \
-p ${NGINX_PORT}:80 \
-p ${NGINX_HTTPS_PORT}:443 \
-p 8080:80 \
-v $PWD:/home/docker \
-v $PWD/nginx.conf:/etc/nginx/conf.d/default.conf \
--network ${NETWORKS} \
--network demo_meetup \
nginx

### Visit [http://localhost:8080](http://localhost:8080)
2 changes: 1 addition & 1 deletion 03-link-container/index.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

echo "hello world in php !";
phpinfo();
1 change: 1 addition & 0 deletions 03-link-container/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ server {

location ~ ^/(index)\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
Expand Down
2 changes: 1 addition & 1 deletion 04-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'

services:

nginx:
web:
image: nginx
ports:
- "8080:80"
Expand Down
2 changes: 1 addition & 1 deletion 04-compose/docker/index.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

echo "hello world in php with docker-compose !";
phpinfo();
1 change: 1 addition & 0 deletions 04-compose/docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ server {

location ~ ^/(index)\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
Expand Down
5 changes: 5 additions & 0 deletions 06-development-env/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# MySQL credentials
MYSQL_ROOT_PASSWORD=root
MYSQL_USER=devops
MYSQL_PASSWORD=devops
MYSQL_DATABASE=demo_meetup
37 changes: 21 additions & 16 deletions 06-development-env/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ version: '3'

services:

nginx:
web:
image: nginx
ports:
- "80:80"
- "8080:80"
volumes:
- ".:/home/docker"
- "./docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro"
Expand All @@ -20,6 +20,11 @@ services:
- "./docker/php.ini:/usr/local/etc/php/conf.d/custom.ini:ro"
networks:
- demo_meetup
environment:
- "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}"
- "MYSQL_USER=${MYSQL_USER}"
- "MYSQL_PASSWORD=${MYSQL_PASSWORD}"
- "MYSQL_DATABASE=${MYSQL_DATABASE}"

db:
image: mysql
Expand All @@ -30,21 +35,21 @@ services:
networks:
- demo_meetup
environment:
- "MYSQL_ROOT_PASSWORD=root"
- "MYSQL_USER=devops"
- "MYSQL_PASSWORD=devops"
- "MYSQL_DATABASE=demo_meetup"
- "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}"
- "MYSQL_USER=${MYSQL_USER}"
- "MYSQL_PASSWORD=${MYSQL_PASSWORD}"
- "MYSQL_DATABASE=${MYSQL_DATABASE}"

# phpmyadmin:
# image: phpmyadmin/phpmyadmin
# ports:
# - "8080:80"
# networks:
# - demo_meetup
# environment:
# - "PMA_HOST=db"
# - "PMA_USER=root"
# - "PMA_PASSWORD=root"
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- "8081:80"
networks:
- demo_meetup
environment:
- "PMA_HOST=db"
- "PMA_USER=root"
- "PMA_PASSWORD=root"

networks:
demo_meetup:
Expand Down
4 changes: 4 additions & 0 deletions 06-development-env/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ RUN apt-get update \
RUN docker-php-ext-install \
mysqli \
pdo_mysql

# Install xdebug extention
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
12 changes: 12 additions & 0 deletions 06-development-env/docker/php.ini
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
date.timezone = Europe/Paris

xdebug.remote_enable = on
xdebug.remote_host = 192.168.1.17
xdebug.remote_connect_back = On
memory_limit = 64M
xdebug.remote_autostart = 1

xdebug.var_display_max_depth = 10
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = "/tmp/xdebugprofiler/"
xdebug.max_nesting_level = 1000
12 changes: 11 additions & 1 deletion 06-development-env/src/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<?php

$bdd = new PDO('mysql:host=db;dbname=demo_meetup', 'root', 'root');
$env = [
'MYSQL_DATABASE' => getenv('MYSQL_DATABASE'),
'MYSQL_USER' => getenv('MYSQL_USER'),
'MYSQL_PASSWORD' => getenv('MYSQL_PASSWORD'),
];

echo 'Getting env var using getenv()';
echo "\n";
var_dump($env);

$bdd = new PDO('mysql:host=db;dbname='.$env['MYSQL_DATABASE'], $env['MYSQL_USER'], $env['MYSQL_PASSWORD']);

var_dump($bdd);

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
## Demo repository for meetup docker_101


[voir slide en version PDF](docker-td.pdf)

0 comments on commit 6916e27

Please sign in to comment.