Showing
7 changed files
with
136 additions
and
0 deletions
.gitignore
0 → 100644
app/docker-compose.yml
0 → 100644
1 | +version: "3" | ||
2 | +services: | ||
3 | + | ||
4 | + web: | ||
5 | + image: nginx | ||
6 | + container_name: nginx | ||
7 | + ports: | ||
8 | + - "8081:80" | ||
9 | + networks: | ||
10 | + mynet: | ||
11 | + ipv4_address: 172.28.0.2 | ||
12 | + volumes: | ||
13 | + - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf | ||
14 | + - ./web:/var/www/html | ||
15 | + restart: on-failure | ||
16 | + links: | ||
17 | + - app | ||
18 | + | ||
19 | + app: | ||
20 | + image: node | ||
21 | + container_name: node | ||
22 | + ports: | ||
23 | + - "8082:80" | ||
24 | + networks: | ||
25 | + mynet: | ||
26 | + ipv4_address: 172.28.0.3 | ||
27 | + working_dir: /app | ||
28 | + volumes: | ||
29 | + - ./node:/app | ||
30 | + - ./config:/app/config | ||
31 | + command: bash -c "npm install && node app.js" | ||
32 | + environment: | ||
33 | + - NODE_ENV=production | ||
34 | + links: | ||
35 | + - db | ||
36 | + depends_on: | ||
37 | + - db | ||
38 | + restart: on-failure | ||
39 | + | ||
40 | + db: | ||
41 | + image: mariadb:10.2 | ||
42 | + container_name: mariadb10.2 | ||
43 | + ports: | ||
44 | + - "33066:3306" | ||
45 | + networks: | ||
46 | + mynet: | ||
47 | + ipv4_address: 172.28.0.4 | ||
48 | + volumes: | ||
49 | + - mariadb:/var/lib/mysql | ||
50 | + - ./config:/config | ||
51 | + environment: | ||
52 | + MYSQL_ROOT_PASSWORD_FILE: ./config/db_password.txt | ||
53 | + MYSQL_DATABASE: maple | ||
54 | + MYSQL_USER: maple | ||
55 | + MYSQL_PASSWORD_FILE: ./config/db_password.txt | ||
56 | + TZ: Asia/Seoul | ||
57 | + command: --character_set_client=utf8 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --character-set-client-handshake=FALSE | ||
58 | + restart: on-failure | ||
59 | + | ||
60 | +volumes: | ||
61 | + mariadb: | ||
62 | + | ||
63 | +networks: | ||
64 | + mynet: | ||
65 | + ipam: | ||
66 | + driver: default | ||
67 | + config: | ||
68 | + - subnet: 172.28.0.0/16 | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
app/nginx/nginx.conf
0 → 100644
1 | +server { | ||
2 | + listen 80; | ||
3 | + server_name localhost; | ||
4 | + access_log /var/log/nginx/access.log.1; | ||
5 | + error_log /var/log/nginx/error.log.1; | ||
6 | + | ||
7 | + location /api { | ||
8 | + proxy_pass http://172.28.0.3; | ||
9 | + } | ||
10 | + | ||
11 | + location / { | ||
12 | + root /var/www/html; | ||
13 | + index index.html; | ||
14 | + } | ||
15 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
app/node/app.js
0 → 100644
1 | +var express = require('express'); | ||
2 | +var app = express(); | ||
3 | +var bodyParser = require('body-parser'); | ||
4 | +var mysql = require('mysql'); | ||
5 | +var fs = require('fs'); | ||
6 | + | ||
7 | +app.use(bodyParser.urlencoded({ extended: false })); | ||
8 | +app.use(bodyParser.json()); | ||
9 | + | ||
10 | +var db; | ||
11 | + | ||
12 | +fs.readFile('./config/db_password.txt', function(err, data) { | ||
13 | + db = mysql.createConnection({ | ||
14 | + host: "172.28.0.4", | ||
15 | + port: 3306, | ||
16 | + user: "root", | ||
17 | + password: data, | ||
18 | + database: "mysql" | ||
19 | + }); | ||
20 | + | ||
21 | + db.connect(); | ||
22 | +}); | ||
23 | + | ||
24 | +app.get('/query', function (req, res) { | ||
25 | + db.query("SHOW DATABASES", | ||
26 | + function(err, results, fields) { | ||
27 | + if (err) throw err; | ||
28 | + var string = JSON.stringify(results); | ||
29 | + res.send(string); | ||
30 | + } | ||
31 | + ); | ||
32 | +}); | ||
33 | + | ||
34 | +var server = app.listen(80); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
app/node/package-lock.json
0 → 100644
This diff is collapsed. Click to expand it.
app/node/package.json
0 → 100644
1 | +{ | ||
2 | + "name": "node", | ||
3 | + "version": "1.0.0", | ||
4 | + "description": "", | ||
5 | + "main": "app.js", | ||
6 | + "scripts": { | ||
7 | + "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | + }, | ||
9 | + "author": "", | ||
10 | + "license": "ISC", | ||
11 | + "dependencies": { | ||
12 | + "express": "^4.17.1", | ||
13 | + "http": "0.0.1-security", | ||
14 | + "mysql": "^2.18.1" | ||
15 | + } | ||
16 | +} |
app/web/index.html
0 → 100644
1 | +hello world | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment