Skip to content

Commit f482922

Browse files
updated code
1 parent 34f52dd commit f482922

31 files changed

+66
-27
lines changed

docker-compose.yml

+26-18
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1-
version: '3.0'
1+
web:
2+
image: nginx:latest
3+
ports:
4+
- "80:80"
5+
volumes:
6+
- ./:/var/www
7+
- ./site.conf:/etc/nginx/conf.d/site.conf
8+
links:
9+
- php
10+
php:
11+
image: nanoninja/php-fpm:latest
12+
volumes:
13+
- ./:/var/www
14+
links:
15+
- db
16+
17+
db:
18+
image: mysql:5.7
19+
volumes:
20+
- /var/lib/mysql
21+
- ./mysql:/tmp/mysql
22+
environment:
23+
- MYSQL_ROOT_PASSWORD=123456
24+
- MYSQL_DATABASE=database
25+
ports:
26+
- "3306:3306"
227

3-
services:
4-
php:
5-
image: nanoninja/php-fpm:latest
6-
volumes:
7-
- ./html:/var/www/html
8-
links:
9-
- db
10-
11-
db:
12-
image: mysql:5.7
13-
volumes:
14-
- /var/lib/mysql
15-
environment:
16-
- MYSQL_ROOT_PASSWORD=123456
17-
- MYSQL_DATABASE=database
18-
ports:
19-
- "3306:3306"

html/.DS_Store

-6 KB
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.

html/example.app1/search.php html/app1/search.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// (1) CONNECT DATABASE
33
// ! CHANGE THESE TO YOUR OWN !
44

5-
define('DB_HOST', 'localhost');
6-
define('DB_NAME', 'demo_user_db');
5+
define('DB_HOST', 'db');
6+
define('DB_NAME', 'database');
77
define('DB_CHARSET', 'utf8');
88
define('DB_USER', 'root');
9-
define('DB_PASSWORD', '');
9+
define('DB_PASSWORD', '123456');
1010

1111
try {
1212
$pdo = new PDO(
@@ -27,4 +27,4 @@
2727
if (isset($_POST['ajax'])) {
2828
echo json_encode($results);
2929
}
30-
?>
30+
?>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

html/example.app2/index.php html/app2/index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@
4545
<!-- [CART] -->
4646
<div id="page-cart" class="ninja"></div>
4747
</body>
48-
</html>
48+
</html>
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22
/* [DATABASE SETTINGS] */
33
// ! CHANGE THESE TO YOUR OWN !
4-
define('DB_HOST', 'localhost');
5-
define('DB_NAME', 'test');
4+
define('DB_HOST', 'db');
5+
define('DB_NAME', 'shopdb');
66
define('DB_CHARSET', 'utf8');
77
define('DB_USER', 'root');
8-
define('DB_PASSWORD', '');
8+
define('DB_PASSWORD', '123456');
99

1010
/* [MUTE NOTIFICATIONS] */
1111
error_reporting(E_ALL & ~E_NOTICE);
@@ -17,4 +17,4 @@
1717
/* [START SESSION] */
1818
session_start();
1919
if (!is_array($_SESSION['cart'])) { $_SESSION['cart'] = []; }
20-
?>
20+
?>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

mysql/run.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
mysql --host=localhost --user=root --password=$MYSQL_ROOT_PASSWORD --port=3306 database < /tmp/mysql/app1/users.sql
3+
4+
mysql --host=localhost --user=root --password=$MYSQL_ROOT_PASSWORD --port=3306 -e "create schema shopdb"
5+
6+
mysql --host=localhost --user=root --password=$MYSQL_ROOT_PASSWORD --port=3306 shopdb < /tmp/mysql/app2/1a-products.sql
7+
mysql --host=localhost --user=root --password=$MYSQL_ROOT_PASSWORD --port=3306 shopdb < /tmp/mysql/app2/1b-orders.sql
8+
mysql --host=localhost --user=root --password=$MYSQL_ROOT_PASSWORD --port=3306 shopdb < /tmp/mysql/app2/1c-orders-items.sql
9+
mysql --host=localhost --user=root --password=$MYSQL_ROOT_PASSWORD --port=3306 shopdb < /tmp/mysql/app2/1d-dummy-products.sql
10+

site.conf

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
server {
2+
listen 80 default_server;
3+
listen [::]:80 default_server;
4+
server_name localhost;
5+
6+
index index.php index.html;
7+
error_log /var/log/nginx/error.log;
8+
access_log /var/log/nginx/access.log;
9+
root /var/www/html;
10+
11+
location ~ \.php$ {
12+
try_files $uri =404;
13+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
14+
fastcgi_pass php:9000;
15+
fastcgi_index index.php;
16+
include fastcgi_params;
17+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
18+
fastcgi_param PATH_INFO $fastcgi_path_info;
19+
}
20+
}
21+

0 commit comments

Comments
 (0)