Skip to content

Instantly share code, notes, and snippets.

@lbrenman
Last active August 13, 2020 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbrenman/7aada36639ab389b456a8d9b32d6d382 to your computer and use it in GitHub Desktop.
Save lbrenman/7aada36639ab389b456a8d9b32d6d382 to your computer and use it in GitHub Desktop.
Publish a Node.js App to Axway's ARS WITH Healthcheck (assets)
FROM node:alpine
WORKDIR '/app'
COPY package.json .
RUN npm install
COPY . .
HEALTHCHECK --interval=5s --start-period=10s --timeout=5s --retries=5 CMD node healthcheck.js
CMD ["npm","start"]
const http = require('http');
const options = {
host: 'localhost',
port: process.env.PORT || 4001,
timeout: 5000,
path: '/'
};
const healthCheck = http.request(options, (res) => {
console.log(`HEALTHCHECK STATUS: ${res.statusCode}`);
if (res.statusCode == 200) {
process.exit(0);
}
else {
process.exit(1);
}
});
healthCheck.on('error', function (err) {
console.error('ERROR = '+err);
process.exit(1);
});
healthCheck.end();
const express = require("express");
const app = express();
app.get("/", (req, res) => {
res.send("Hello Node/Express App!!!");
});
app.listen(4001, () => {
console.log("listening on port 4001");
});
{
"version": "0.1.0",
"dependencies": {
"express": "*"
},
"scripts": {
"start": "node index.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment