diff --git a/.gitea/workflows/build-image.yml b/.gitea/workflows/build-image.yml index 1a438d3..a847633 100644 --- a/.gitea/workflows/build-image.yml +++ b/.gitea/workflows/build-image.yml @@ -13,15 +13,15 @@ jobs: # change mirror to kku.ac.th for faster package downloading sudo sed -i 's@http://archive.ubuntu.com@http://mirror.kku.ac.th@g' /etc/apt/sources.list.d/ubuntu.sources sudo apt update && sudo apt install nodejs npm curl -y - - name: Install project dependencies - run: | - npm install - - name: Testing APIs - run: | - chmod +x test.sh - ./test.sh - name: Build docker image run: | + mv Dockerfile ../ + mv entrypoint ../ + cd ../ + set +e + docker rm $(docker stop $(docker ps -a -q --filter ancestor=accounting-api:latest --format="{{.ID}}")) + set -e + docker image rm -f accounting-api:latest docker build . -t accounting-api:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f1492da..6d565d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,16 @@ RUN chmod +x ./entrypoint RUN apk update && apk add npm -RUN mkdir /server +ADD micro-service-api /server -ADD node_modules /server/node_modules -ADD package-lock.json /server/package-lock.json -ADD package.json /server/package.json +RUN mv /server/start-accountingwep.sh / +RUN mv /server/start-login.sh / +RUN mv /server/start-ttc.sh / -ADD exthernal-login-api /server/exthernal-login-api -ADD exthernal-ttc-api /server/exthernal-ttc-api +RUN chmod +x /start-accountingwep.sh +RUN chmod +x /start-login.sh +RUN chmod +x /start-ttc.sh + +RUN cd /server && npm install ENTRYPOINT ["/entrypoint"] diff --git a/entrypoint b/entrypoint index eac4d14..c5bc900 100644 --- a/entrypoint +++ b/entrypoint @@ -1,6 +1,4 @@ #!/bin/sh -cd /server/exthernal-login-api -& npm start - -cd /server/exthernal-accountingwep-api -& npm start \ No newline at end of file +./start-login.sh & +./start-ttc.sh & +exec ./start-accountingwep.sh \ No newline at end of file diff --git a/exthernal-accountingwep-api/.env b/exthernal-accountingwep-api/.env index c57b980..0402cc7 100644 --- a/exthernal-accountingwep-api/.env +++ b/exthernal-accountingwep-api/.env @@ -2,7 +2,7 @@ PJ_NAME=exthernal-wepaccounting-api # database -PG_HOST=10.9.0.0 +PG_HOST=accounting-database PG_USER=postgres PG_PASS=ttc@2026 PG_DB=ttc @@ -13,7 +13,7 @@ SMTP_USER=lalisakuty@gmail.com SMTP_PASS=lurl pckw qugk tzob # REDIS -REDIS_HOST=10.9.0.0 +REDIS_HOST=redis REDIS_PORT=6379 OTP_TTL_SECONDS=300 diff --git a/exthernal-accountingwep-api/src/routes/route.js b/exthernal-accountingwep-api/src/routes/route.js index bf6eee9..18c4ced 100644 --- a/exthernal-accountingwep-api/src/routes/route.js +++ b/exthernal-accountingwep-api/src/routes/route.js @@ -3,7 +3,7 @@ import { accountingSetup } from '../controllers/accountingSetupController.js' import { accountingSearch } from '../controllers/accountingSearchController.js' import { accountingSum } from '../controllers/accountingSumController.js' import { accountingAdd } from '../controllers/accountingAddController.js' -import { reportController } from '../controllers/ReportController.js' +import { reportController } from '../controllers/reportController.js' // import { authMiddleware } from '../middlewares/auth.js' // import { sendResponse } from '../utils/response.js' diff --git a/exthernal-login-api/.env b/exthernal-login-api/.env index d5df980..484b174 100644 --- a/exthernal-login-api/.env +++ b/exthernal-login-api/.env @@ -2,7 +2,7 @@ PJ_NAME=exthernal-login-api # database -PG_HOST=10.9.0.0 +PG_HOST=accounting-database PG_USER=postgres PG_PASS=ttc@2026 PG_DB=ttc @@ -13,7 +13,7 @@ SMTP_USER=lalisakuty@gmail.com SMTP_PASS=lurl pckw qugk tzob # REDIS -REDIS_HOST=10.9.0.0 +REDIS_HOST=redis REDIS_PORT=6379 OTP_TTL_SECONDS=300 diff --git a/exthernal-ttc-api/.env b/exthernal-ttc-api/.env index c93c6dd..6c13bfe 100644 --- a/exthernal-ttc-api/.env +++ b/exthernal-ttc-api/.env @@ -2,7 +2,7 @@ PJ_NAME=exthernal-ttc-api # database -PG_HOST=10.9.0.0 +PG_HOST=accounting-database PG_USER=postgres PG_PASS=ttc@2026 PG_DB=ttc @@ -13,7 +13,7 @@ SMTP_USER=lalisakuty@gmail.com SMTP_PASS=lurl pckw qugk tzob # REDIS -REDIS_HOST=127.0.0.1 +REDIS_HOST=redis REDIS_PORT=6379 OTP_TTL_SECONDS=300 diff --git a/exthernal-ttc-api/src/routes/route.js b/exthernal-ttc-api/src/routes/route.js index 68e4b3e..319c69a 100644 --- a/exthernal-ttc-api/src/routes/route.js +++ b/exthernal-ttc-api/src/routes/route.js @@ -5,7 +5,7 @@ import { budgetAdd } from '../controllers/budgetAddController.js' import { projectSearch } from '../controllers/projectSearchController.js' import { projectAdd } from '../controllers/projectAddController.js' import { budgetExpense } from '../controllers/budgetExpenseController.js' -import { reportController } from '../controllers/ReportController.js' +import { reportController } from '../controllers/reportController.js' import { transactionSearch } from '../controllers/transactionSearchController.js' // import { authMiddleware } from '../middlewares/auth.js' diff --git a/start-accountingwep.sh b/start-accountingwep.sh new file mode 100644 index 0000000..f009920 --- /dev/null +++ b/start-accountingwep.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cd /server/exthernal-accountingwep-api +npm start \ No newline at end of file diff --git a/start-login.sh b/start-login.sh new file mode 100644 index 0000000..57c2836 --- /dev/null +++ b/start-login.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cd /server/exthernal-login-api +npm start \ No newline at end of file diff --git a/start-ttc.sh b/start-ttc.sh new file mode 100644 index 0000000..daf3de5 --- /dev/null +++ b/start-ttc.sh @@ -0,0 +1,3 @@ +#!/bin/sh +cd /server/exthernal-ttc-api +npm start \ No newline at end of file