윤준석

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