윤준석

ADD: deployment setting

add dockerfile, docker-compose, .dockerignore to nodejs server

add nodejs server to docker-compose this application
...@@ -4,5 +4,6 @@ docker build -t daangn-api-server ./daangn/ ...@@ -4,5 +4,6 @@ docker build -t daangn-api-server ./daangn/
4 docker build -t joongna-api-server ./joongna/ 4 docker build -t joongna-api-server ./joongna/
5 docker build -t bunjang-api-server ./bunjang/ 5 docker build -t bunjang-api-server ./bunjang/
6 docker build -t mamuri-db ./database/ 6 docker build -t mamuri-db ./database/
7 +docker build -t mamuri-server ./server/
7 8
8 docker-compose up -d 9 docker-compose up -d
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -4,7 +4,7 @@ services: ...@@ -4,7 +4,7 @@ services:
4 db: 4 db:
5 image: mamuri-db 5 image: mamuri-db
6 restart: always 6 restart: always
7 - container_name: mamuri-db-container 7 + container_name: mamuri-db
8 ports: 8 ports:
9 - '13060:3306' 9 - '13060:3306'
10 env_file: 10 env_file:
...@@ -12,23 +12,30 @@ services: ...@@ -12,23 +12,30 @@ services:
12 volumes: 12 volumes:
13 - "/usr/mysql/data:/var/lib/mysql" 13 - "/usr/mysql/data:/var/lib/mysql"
14 14
15 + server:
16 + image: mamuri-server
17 + restart: always
18 + container_name: mamuri-server
19 + ports:
20 + - '8080:8080'
21 +
15 daangn_api: 22 daangn_api:
16 image: daangn-api-server 23 image: daangn-api-server
17 restart: always 24 restart: always
18 - container_name: daangn-api-server-container 25 + container_name: daangn-api-server
19 ports: 26 ports:
20 - '18080:8080' 27 - '18080:8080'
21 28
22 joongna_api: 29 joongna_api:
23 image: joongna-api-server 30 image: joongna-api-server
24 restart: always 31 restart: always
25 - container_name: joongna-api-server-container 32 + container_name: joongna-api-server
26 ports: 33 ports:
27 - '18081:8080' 34 - '18081:8080'
28 35
29 bunjang_api: 36 bunjang_api:
30 image: bunjang-api-server 37 image: bunjang-api-server
31 restart: always 38 restart: always
32 - container_name: bunjang-api-server-container 39 + container_name: bunjang-api-server
33 ports: 40 ports:
34 - '18082:8080' 41 - '18082:8080'
...\ No newline at end of file ...\ No newline at end of file
......
1 +node_modules
2 +npm-debug.log
...\ No newline at end of file ...\ No newline at end of file
1 +FROM node:17.9.0-alpine
2 +
3 +WORKDIR /src
4 +COPY . /src
5 +
6 +RUN npm install
7 +
8 +EXPOSE 8080
9 +CMD ["node", "app.js"]
...\ No newline at end of file ...\ No newline at end of file
...@@ -12,7 +12,8 @@ sequelize ...@@ -12,7 +12,8 @@ sequelize
12 console.log("database connection complete"); 12 console.log("database connection complete");
13 }) 13 })
14 .catch((err) => { 14 .catch((err) => {
15 - console.log("database connection failed"); 15 + console.log("database connection failed. restart the server");
16 + process.exit(-1)
16 }); 17 });
17 18
18 // Load .env configuration 19 // Load .env configuration
...@@ -32,6 +33,6 @@ app.post("/webhook", line.middleware(config), (req, res) => { ...@@ -32,6 +33,6 @@ app.post("/webhook", line.middleware(config), (req, res) => {
32 }); 33 });
33 }); 34 });
34 35
35 -const port = 1231; 36 +const port = 8080;
36 app.listen(port); 37 app.listen(port);
37 console.log(`listening...\nport : ${port}`); 38 console.log(`listening...\nport : ${port}`);
......
...@@ -33,7 +33,7 @@ const db = require("../apis/database"); ...@@ -33,7 +33,7 @@ const db = require("../apis/database");
33 // database.getAllKeywords = async function() 33 // database.getAllKeywords = async function()
34 34
35 // Import credentials for Line chatbot 35 // Import credentials for Line chatbot
36 -require("dotenv").config({ path: __dirname + "/../.env" }); 36 +require("dotenv").config({ path: __dirname + "/../config/.env" });
37 const config = { 37 const config = {
38 channelAccessToken: process.env.channelAccessToken, 38 channelAccessToken: process.env.channelAccessToken,
39 channelSecret: process.env.channelSecret, 39 channelSecret: process.env.channelSecret,
......
...@@ -4,7 +4,7 @@ const bunjangSingleSearch = (keyword) => { ...@@ -4,7 +4,7 @@ const bunjangSingleSearch = (keyword) => {
4 return Promise.resolve( 4 return Promise.resolve(
5 axios 5 axios
6 .get( 6 .get(
7 - `http://localhost:18082/api/v2/bunjang/${encodeURIComponent( 7 + `http://bunjang-api-server:8080/api/v2/bunjang/${encodeURIComponent(
8 keyword 8 keyword
9 )}` 9 )}`
10 ) 10 )
...@@ -17,7 +17,7 @@ const bunjangMultiSearch = (keyword) => { ...@@ -17,7 +17,7 @@ const bunjangMultiSearch = (keyword) => {
17 return Promise.resolve( 17 return Promise.resolve(
18 axios 18 axios
19 .get( 19 .get(
20 - `http://localhost:18082/api/v2/bunjang/${encodeURIComponent( 20 + `http://bunjang-api-server:8080/api/v2/bunjang/${encodeURIComponent(
21 keyword 21 keyword
22 )}` 22 )}`
23 ) 23 )
......
...@@ -4,7 +4,7 @@ const daangnSingleSearch = (keyword) => { ...@@ -4,7 +4,7 @@ const daangnSingleSearch = (keyword) => {
4 return Promise.resolve( 4 return Promise.resolve(
5 axios 5 axios
6 .get( 6 .get(
7 - `http://localhost:18080/api/v2/daangn/${encodeURIComponent(keyword)}` 7 + `http://daangn-api-server:8080/api/v2/daangn/${encodeURIComponent(keyword)}`
8 ) 8 )
9 .then((res) => res.data["items"][0]) 9 .then((res) => res.data["items"][0])
10 .catch((e) => undefined) 10 .catch((e) => undefined)
...@@ -15,7 +15,7 @@ const daangnMultiSearch = (keyword) => { ...@@ -15,7 +15,7 @@ const daangnMultiSearch = (keyword) => {
15 return Promise.resolve( 15 return Promise.resolve(
16 axios 16 axios
17 .get( 17 .get(
18 - `http://localhost:18080/api/v2/daangn/${encodeURIComponent(keyword)}` 18 + `http://daangn-api-server:8080/api/v2/daangn/${encodeURIComponent(keyword)}`
19 ) 19 )
20 .then((res) => res.data["items"]) 20 .then((res) => res.data["items"])
21 .catch((e) => undefined) 21 .catch((e) => undefined)
......
...@@ -4,7 +4,7 @@ const joongnaSingleSearch = (keyword) => { ...@@ -4,7 +4,7 @@ const joongnaSingleSearch = (keyword) => {
4 return Promise.resolve( 4 return Promise.resolve(
5 axios 5 axios
6 .get( 6 .get(
7 - `http://localhost:18081/api/v2/joongna/${encodeURIComponent( 7 + `http://joongna-api-server:8080/api/v2/joongna/${encodeURIComponent(
8 keyword 8 keyword
9 )}` 9 )}`
10 ) 10 )
...@@ -17,7 +17,7 @@ const joongnaMultiSearch = (keyword) => { ...@@ -17,7 +17,7 @@ const joongnaMultiSearch = (keyword) => {
17 return Promise.resolve( 17 return Promise.resolve(
18 axios 18 axios
19 .get( 19 .get(
20 - `http://localhost:18081/api/v2/joongna/${encodeURIComponent( 20 + `http://joongna-api-server:8080/api/v2/joongna/${encodeURIComponent(
21 keyword 21 keyword
22 )}` 22 )}`
23 ) 23 )
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
3 "username": "root", 3 "username": "root",
4 "password": "mamuri", 4 "password": "mamuri",
5 "database": "mamuri_db", 5 "database": "mamuri_db",
6 - "host": "127.0.0.1", 6 + "host": "mamuri-db",
7 - "port": "13060", 7 + "port": "3306",
8 "dialect": "mysql" 8 "dialect": "mysql"
9 }, 9 },
10 "test": { 10 "test": {
......
1 +#!/usr/bin/env bash
2 +
3 +docker build -t mamuri-db ../database/
4 +docker build -t mamuri-server .
5 +
6 +docker-compose up -d
...\ No newline at end of file ...\ No newline at end of file
1 +version: '3'
2 +
3 +services:
4 + db:
5 + image: mamuri-db
6 + restart: always
7 + container_name: mamuri-db
8 + ports:
9 + - '13060:3306'
10 + env_file:
11 + - "../database/mysql_init/.env"
12 + volumes:
13 + - "/usr/mysql/data:/var/lib/mysql"
14 +
15 + server:
16 + image: mamuri-server
17 + restart: always
18 + container_name: mamuri-server
19 + ports:
20 + - '8080:8080'
21 +
22 + daangn_api:
23 + image: daangn-api-server
24 + restart: always
25 + container_name: daangn-api-server
26 + ports:
27 + - '18080:8080'
28 +
29 + joongna_api:
30 + image: joongna-api-server
31 + restart: always
32 + container_name: joongna-api-server
33 + ports:
34 + - '18081:8080'
35 +
36 + bunjang_api:
37 + image: bunjang-api-server
38 + restart: always
39 + container_name: bunjang-api-server
40 + ports:
41 + - '18082:8080'
...\ No newline at end of file ...\ No newline at end of file
1 +#!/usr/bin/env bash
2 +
3 +docker-compose down
4 +
5 +docker image rm mamuri-server
6 +docker image rm mamuri-db
...\ No newline at end of file ...\ No newline at end of file
...@@ -6,3 +6,4 @@ docker image rm daangn-api-server ...@@ -6,3 +6,4 @@ docker image rm daangn-api-server
6 docker image rm joongna-api-server 6 docker image rm joongna-api-server
7 docker image rm bunjang-api-server 7 docker image rm bunjang-api-server
8 docker image rm mamuri-db 8 docker image rm mamuri-db
9 +docker image rm mamuri-server
......