forked from ptarmiganlabs/butler-spyglass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Add missing Docker build files
build: Add Docker healthcheck Implements #23
- Loading branch information
1 parent
e3294d0
commit ea0518e
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
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
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"] | ||
|
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
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
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(); |