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

Commit

Permalink
init repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibaut-gauvin committed Sep 25, 2017
0 parents commit a5827fb
Show file tree
Hide file tree
Showing 20 changed files with 314 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
05-compose-with-volum/.data
06-development-env/.data
28 changes: 28 additions & 0 deletions 01-dockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM nginx

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

# Build l'image et la tagger
# docker build -t nginx:demo_meetup .

# Voir les images docker :
# docker images

# Lancement du container à partir de l'image
# docker run -d --name web -p 8080:80 nginx:demo_meetup

# Visiter http://localhost:8080

# Voir les logs de Nginx
# docker logs web

# ---

# Stoper le container
# docker stop web

# Supprimer le container
# docker rm web

# Supprimer les images
# docker rmi nginx:demo_meetup nginx:latest
9 changes: 9 additions & 0 deletions 01-dockerfile/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>hello world</title>
</head>
<body>
<p>hello world !</p>
</body>
</html>
33 changes: 33 additions & 0 deletions 02-volumes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## NOTICE


### notes :

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

echo $PWD
/home/thibaut/meetup_docker_101/02-volumes


### Use Nginx official image & mount custom config inside :

docker run -d \
--name web \
-p 8080:80 \
-v $PWD:/home/docker \
-v $PWD/nginx.conf:/etc/nginx/conf.d/default.conf \
nginx

### Connect to the running container and view files :

# Connect to the container
docker exec -ti web /bin/bash

# View the files
root@51aafa93a21e:/# cd /home/docker/
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
9 changes: 9 additions & 0 deletions 02-volumes/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {
listen 80;
root /home/docker;

index toto.html;

error_log /dev/fd/1;
access_log /dev/fd/1;
}
9 changes: 9 additions & 0 deletions 02-volumes/toto.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>hello world</title>
</head>
<body>
<p>hello world !</p>
</body>
</html>
34 changes: 34 additions & 0 deletions 03-link-container/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## NOTICE

How to bind to container together ?
example with nginx + php7.1-fpm

(don't forget to cd to this directory before)


### Create docker network:

docker network create demo_meetup


### Star PHP container :

docker run -d \
--name php \
-v $PWD:/home/docker \
--network demo_meetup \
php:7.1-fpm


### Start Nginx container :

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

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

echo "hello world in php !";
23 changes: 23 additions & 0 deletions 03-link-container/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
listen 80;

root /home/docker;

location / {
try_files $uri @rewriteapp;
}

location @rewriteapp {
rewrite ^(.*)$ /index.php/$1 last;
}

location ~ ^/(index)\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
}

error_log /dev/fd/1;
access_log /dev/fd/1;
}
26 changes: 26 additions & 0 deletions 04-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3'

services:

nginx:
image: nginx
ports:
- "8080:80"
volumes:
- ".:/home/docker"
- "./docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro"
networks:
- demo_meetup

php:
image: php:7.1-fpm
volumes:
- "./docker:/home/docker"
- "./docker/php.ini:/usr/local/etc/php/conf.d/custom.ini:ro"
working_dir: "/home/docker"
networks:
- demo_meetup

networks:
demo_meetup:
driver: bridge
3 changes: 3 additions & 0 deletions 04-compose/docker/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

echo "hello world in php with docker-compose !";
23 changes: 23 additions & 0 deletions 04-compose/docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
listen 80;

root /home/docker;

location / {
try_files $uri @rewriteapp;
}

location @rewriteapp {
rewrite ^(.*)$ /index.php/$1 last;
}

location ~ ^/(index)\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
}

error_log /dev/fd/1;
access_log /dev/fd/1;
}
1 change: 1 addition & 0 deletions 04-compose/docker/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
date.timezone = Europe/Paris
15 changes: 15 additions & 0 deletions 05-compose-with-volum/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3'

services:

db:
image: mysql
ports:
- "3306:3306"
volumes:
- "./.data/db:/var/lib/mysql"
environment:
- "MYSQL_ROOT_PASSWORD=root"
- "MYSQL_USER=devops"
- "MYSQL_PASSWORD=devops"
- "MYSQL_DATABASE=demo_meetup"
51 changes: 51 additions & 0 deletions 06-development-env/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: '3'

services:

nginx:
image: nginx
ports:
- "80:80"
volumes:
- ".:/home/docker"
- "./docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro"
networks:
- demo_meetup

php:
build:
context: docker/
volumes:
- "./src:/home/docker"
- "./docker/php.ini:/usr/local/etc/php/conf.d/custom.ini:ro"
networks:
- demo_meetup

db:
image: mysql
ports:
- "3306:3306"
volumes:
- "./.data/db:/var/lib/mysql"
networks:
- demo_meetup
environment:
- "MYSQL_ROOT_PASSWORD=root"
- "MYSQL_USER=devops"
- "MYSQL_PASSWORD=devops"
- "MYSQL_DATABASE=demo_meetup"

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

networks:
demo_meetup:
driver: bridge
12 changes: 12 additions & 0 deletions 06-development-env/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM php:7.1-fpm

# Install packages
RUN apt-get update \
&& apt-get install -y \
libicu-dev \
zlib1g-dev

# Install mysql php driver
RUN docker-php-ext-install \
mysqli \
pdo_mysql
23 changes: 23 additions & 0 deletions 06-development-env/docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
listen 80;

root /home/docker;

location / {
try_files $uri @rewriteapp;
}

location @rewriteapp {
rewrite ^(.*)$ /index.php/$1 last;
}

location ~ ^/(index)\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
}

error_log /dev/fd/1;
access_log /dev/fd/1;
}
1 change: 1 addition & 0 deletions 06-development-env/docker/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
date.timezone = Europe/Paris
8 changes: 8 additions & 0 deletions 06-development-env/src/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

$bdd = new PDO('mysql:host=db;dbname=demo_meetup', 'root', 'root');

var_dump($bdd);

// try to visit http://localhost:8080
// you see an PDO object
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## Demo repository for meetup docker_101

0 comments on commit a5827fb

Please sign in to comment.