diff --git a/DevDockerfile b/DevDockerfile index d08e13a9..8133b738 100644 --- a/DevDockerfile +++ b/DevDockerfile @@ -4,8 +4,13 @@ FROM node:18-bullseye ENV APPDIR=/opt/service +# Set environment variables from build arguments ARG BUILD_NUMBER=0 -ENV CRAWLER_BUILD_NUMBER=$BUILD_NUMBER +ENV BUILD_NUMBER=$APP_VERSION +ARG APP_VERSION="UNKNOWN" +ENV APP_VERSION=$APP_VERSION +ARG BUILD_SHA="UNKNOWN" +ENV BUILD_SHA=$BUILD_SHA # Ruby and Python Dependencies RUN apt-get update && apt-get install -y --no-install-recommends --no-install-suggests curl bzip2 build-essential libssl-dev libreadline-dev zlib1g-dev cmake python3 python3-dev python3-pip xz-utils libxml2-dev libxslt1-dev libpopt0 && \ diff --git a/Dockerfile b/Dockerfile index 039d909e..86ca915e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,13 @@ FROM node:18-bullseye ENV APPDIR=/opt/service +# Set environment variables from build arguments ARG BUILD_NUMBER=0 -ENV CRAWLER_BUILD_NUMBER=$BUILD_NUMBER +ENV BUILD_NUMBER=$APP_VERSION +ARG APP_VERSION="UNKNOWN" +ENV APP_VERSION=$APP_VERSION +ARG BUILD_SHA="UNKNOWN" +ENV BUILD_SHA=$BUILD_SHA # Ruby and Python Dependencies RUN apt-get update && apt-get install -y --no-install-recommends --no-install-suggests curl bzip2 build-essential libssl-dev libreadline-dev zlib1g-dev cmake python3 python3-dev python3-pip xz-utils libxml2-dev libxslt1-dev libpopt0 && \ diff --git a/config/cdConfig.js b/config/cdConfig.js index d71b6bd6..b6b72828 100644 --- a/config/cdConfig.js +++ b/config/cdConfig.js @@ -135,6 +135,8 @@ module.exports = { attenuation: { ttl: 3000 } - } + }, + appVersion: config.get('APP_VERSION'), + buildsha: config.get('BUILD_SHA') } } diff --git a/ghcrawler/app.js b/ghcrawler/app.js index 20af0261..b61a8a0c 100644 --- a/ghcrawler/app.js +++ b/ghcrawler/app.js @@ -22,9 +22,7 @@ function configureApp(service, logger) { app.use('/requests', require('./routes/requests')(service)) // to keep AlwaysOn flooding logs with errors - app.get('/', (request, response) => { - response.helpers.send.noContent() - }) + app.use('/', require('./routes/index')(config.get('BUILD_SHA'), config.get('APP_VERSION'))) // Catch 404 and forward to error handler const requestHandler = (request, response, next) => { diff --git a/ghcrawler/routes/index.js b/ghcrawler/routes/index.js new file mode 100644 index 00000000..24ed370e --- /dev/null +++ b/ghcrawler/routes/index.js @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation and others. Licensed under the MIT license. +// SPDX-License-Identifier: MIT +const express = require('express') +const router = express.Router() + +router.get('/', function (req, res) { + const msg = `{ "status": "OK", "version": "${version}", "sha": "${sha}" }` + res.status(200).send(msg) +}) + +module.exports = router + +let version +let sha +function setup(buildsha, appVersion) { + version = appVersion + sha = buildsha + return router +} +module.exports = setup