diff --git a/.vscode/launch.json b/.vscode/launch.json index 4fde12e10c..f04073d805 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -41,6 +41,20 @@ "restart": true, "autoAttachChildProcesses": true }, + { + "address": "127.0.0.1", + "localRoot": "${workspaceFolder}/ProbeAPI", + "name": "Probe API: Debug with Docker", + "port": 9932, + "remoteRoot": "/usr/src/app", + "request": "attach", + "skipFiles": [ + "/**" + ], + "type": "node", + "restart": true, + "autoAttachChildProcesses": true + }, { "address": "127.0.0.1", "localRoot": "${workspaceFolder}/Workflow", diff --git a/ProbeAPI/.dockerignore b/ProbeAPI/.dockerignore index c246ae156e..3ff05dd7b8 100644 --- a/ProbeAPI/.dockerignore +++ b/ProbeAPI/.dockerignore @@ -1,9 +1,56 @@ -node_modules/ -.vscode/ +.git + +node_modules +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# dependencies +/node_modules +node_modules + +.idea +# testing +/coverage + +# production +/build + +# misc .DS_Store -.env + +env.js npm-debug.log* yarn-debug.log* yarn-error.log* -yarn.lock \ No newline at end of file + +yarn.lock +Untitled-1 +*.local.sh +*.local.yaml +run +stop + +nohup.out* + +encrypted-credentials.tar +encrypted-credentials/ + +_README.md + +# Important Add production values to gitignore. +values-saas-production.yaml +kubernetes/values-saas-production.yaml + +/private + +/tls_cert.pem +/tls_key.pem +/keys + +temp_readme.md + +tests/coverage + +settings.json + +GoSDK/tester/ \ No newline at end of file diff --git a/ProbeAPI/.env b/ProbeAPI/.env deleted file mode 100644 index 0376abff05..0000000000 --- a/ProbeAPI/.env +++ /dev/null @@ -1,7 +0,0 @@ -MONGO_URL=mongodb://localhost:27017/oneuptimedb -ONEUPTIME_SECRET=f414c23b4cdf4e84a6a66ecfd528eff2 -SLACK_ERROR_LOG_WEBHOOK=https://hooks.slack.com/services/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 -SLACK_ERROR_LOG_CHANNEL=oneuptime-engineering -PORT=3400 -REALTIME_URL=http://localhost:3300 -DB_NAME=oneuptimedb \ No newline at end of file diff --git a/ProbeAPI/.env.tpl b/ProbeAPI/.env.tpl new file mode 100644 index 0000000000..c155eb0178 --- /dev/null +++ b/ProbeAPI/.env.tpl @@ -0,0 +1 @@ +PORT={{ .Env.PROBE_API_PORT }} \ No newline at end of file diff --git a/ProbeAPI/API/Probe.ts b/ProbeAPI/API/Probe.ts deleted file mode 100755 index 5159134329..0000000000 --- a/ProbeAPI/API/Probe.ts +++ /dev/null @@ -1,42 +0,0 @@ -import Express, { - ExpressRequest, - ExpressResponse, - ExpressRouter, -} from 'CommonServer/Utils/Express'; - -import ProbeAuthorization from 'CommonServer/Middleware/ProbeAuthorization'; -import Response from 'CommonServer/Utils/Response'; -import Exception from 'Common/Types/Exception/Exception'; -import PositiveNumber from 'Common/Types/PositiveNumber'; - -const router: ExpressRouter = Express.getRouter(); - -router.get( - '/monitors', - ProbeAuthorization.isAuthorizedProbeMiddleware, - async (req: ExpressRequest, res: ExpressResponse) => { - try { - // const oneUptimeRequest: OneUptimeRequest = req as OneUptimeRequest; - // const limit: PositiveNumber = new PositiveNumber( - // parseInt((req.query['limit'] as string) || '10') - // ); - - // const monitors: Array = - // await MonitorService.getMonitorsNotPingedByProbeInLastMinute( - // (oneUptimeRequest.probe as ProbeRequest).id, - // limit - // ); - - return Response.sendJsonArrayResponse( - req, - res, - [], - new PositiveNumber(0) - ); - } catch (error) { - return Response.sendErrorResponse(req, res, error as Exception); - } - } -); - -export default router; diff --git a/ProbeAPI/Dockerfile.tpl b/ProbeAPI/Dockerfile.tpl index 2289bc0342..f67b152faa 100755 --- a/ProbeAPI/Dockerfile.tpl +++ b/ProbeAPI/Dockerfile.tpl @@ -1,5 +1,5 @@ # -# OneUptime-ProbeAPI Dockerfile +# OneUptime-probe-api Dockerfile # # Pull base image nodejs image. @@ -11,6 +11,10 @@ RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm co # Install bash. RUN apk update && apk add bash && apk add curl + +# Install python +RUN apk update && apk add --no-cache --virtual .gyp python3 make g++ + #Use bash shell by default SHELL ["/bin/bash", "-c"] @@ -55,6 +59,7 @@ COPY ./ProbeAPI/package*.json /usr/src/app/ RUN npm install # Expose ports. +# - 3400: OneUptime-probe-api EXPOSE 3400 {{ if eq .Env.ENVIRONMENT "development" }} @@ -68,3 +73,4 @@ RUN npm run compile #Run the app CMD [ "npm", "start" ] {{ end }} + diff --git a/ProbeAPI/Tests/index.test.ts b/ProbeAPI/Tests/index.test.ts deleted file mode 100644 index 2d530fc802..0000000000 --- a/ProbeAPI/Tests/index.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -test('two plus two is four', () => { - expect(2 + 2).toBe(4); -}); diff --git a/config.tpl.env b/config.tpl.env index a13a34d441..a28e18aef0 100644 --- a/config.tpl.env +++ b/config.tpl.env @@ -76,6 +76,7 @@ DASHBOARD_API_PORT=3002 API_DOCS_PORT=1445 WORKFLOW_PORT=3099 ALERT_PORT=3088 +PROBE_API_PORT=3400 FILE_PORT=3125 HOME_PORT=1444 IDENTITY_PORT=3087 diff --git a/docker-compose.tpl.yml b/docker-compose.tpl.yml index a9127fd653..b596d75755 100644 --- a/docker-compose.tpl.yml +++ b/docker-compose.tpl.yml @@ -422,7 +422,49 @@ services: {{ end }} - + probe-api: + ports: + - '3400:3400' + {{ if eq .Env.ENVIRONMENT "development" }} + - '9932:9229' # Debugging port. + {{ end }} + {{ if or (eq .Env.ENVIRONMENT "development") (eq .Env.ENVIRONMENT "ci") }} + build: + network: host + context: . + dockerfile: ./ProbeAPI/Dockerfile + {{ else }} + image: oneuptime/probe-api:{{ .Env.APP_TAG }} + {{ end }} + restart: always + env_file: + - ./Common/.env + - ./CommonServer/.env + - ./ProbeAPI/.env + + depends_on: + - redis + - postgres + - mail + links: + - redis + - postgres + - mail + {{ if eq .Env.ENVIRONMENT "development" }} + volumes: + - ./ProbeAPI:/usr/src/app + # Use node modules of the container and not host system. + # https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder + - /usr/src/app/node_modules/ + - ./Common:/usr/src/Common + - ./Model:/usr/src/Model + - ./CommonServer:/usr/src/CommonServer + - ./CommonUI:/usr/src/CommonUI + - /usr/src/Common/node_modules/ + - /usr/src/CommonUI/node_modules/ + - /usr/src/CommonServer/node_modules/ + - /usr/src/Model/node_modules/ + {{ end }} file: ports: