-
-
Save lbrenman/7aada36639ab389b456a8d9b32d6d382 to your computer and use it in GitHub Desktop.
Publish a Node.js App to Axway's ARS WITH Healthcheck (assets)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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