Skip to content

Commit

Permalink
build: Add missing Docker build files
Browse files Browse the repository at this point in the history
build: Add Docker healthcheck
Implements #23
  • Loading branch information
mountaindude committed Mar 12, 2023
1 parent e3294d0 commit ea0518e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Build Docker image for Amd64
FROM node:19-bullseye-slim

# Add metadata about the image
LABEL maintainer="Göran Sander mountaindude@ptarmiganlabs.com"
LABEL description="Extract data lineage, load scripts and data connections from Qlik Sense."

# Create app dir inside container
WORKDIR /nodeapp

# Install app dependencies separately (creating a separate layer for node_modules, effectively caching them between image rebuilds)
COPY package.json .
RUN npm install

# Copy app's source files
COPY . .

# Create and use non-root user
RUN groupadd -r nodejs \
&& useradd -m -r -g nodejs nodejs

USER nodejs

# Set up Docker healthcheck
HEALTHCHECK --interval=12s --timeout=12s --start-period=30s CMD ["node", "docker-healthcheck.js"]

CMD ["node", "butler-spyglass.js"]

13 changes: 13 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [2.0.2](https://github.com/ptarmiganlabs/butler-spyglass/compare/butler-spyglass-v2.0.1...butler-spyglass-v2.0.2) (2023-03-12)


### Documentation

* Add status badge to readme file ([f060f9a](https://github.com/ptarmiganlabs/butler-spyglass/commit/f060f9a4a71a8e6be4eec67fcaef9c8b39ea1337))
* Re-written most of docs wrt 2.x release ([1d7cb6d](https://github.com/ptarmiganlabs/butler-spyglass/commit/1d7cb6d353c6fc8ebc7a47d05c0e63080a094ef3))


### Build pipeline

* Disable MQTT messages from Docker build workflow ([f6b1712](https://github.com/ptarmiganlabs/butler-spyglass/commit/f6b17123b08e1566c20c2149add37fa2fe4954a8))

## [2.0.1](https://github.com/ptarmiganlabs/butler-spyglass/compare/butler-spyglass-v2.0.0...butler-spyglass-v2.0.1) (2023-03-10)


Expand Down
27 changes: 27 additions & 0 deletions docker-healthcheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* eslint-disable no-console */
// Set up REST endpoint for Docker healthchecks
const httpHealth = require('http');

const optionsHealth = {
host: 'localhost',
port: '12398',
path: '/health',
timeout: 2000,
};

const requestHealth = httpHealth.request(optionsHealth, (res) => {
console.log(`STATUS Docker health: ${res.statusCode}`);
if (res.statusCode === 200) {
process.exit(0);
} else {
process.exit(1);
}
});

requestHealth.on('error', (err) => {
console.log('ERROR Docker health:');
console.log(err);
process.exit(1);
});

requestHealth.end();

0 comments on commit ea0518e

Please sign in to comment.