-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vulnerability dashboard: Add a way to start a local vulnerability das…
…hboard with Docker (#17676) Related to: fleetdm/confidential#5637 Changes: - Added a way to start a vulnerability dashboard with Docker. - Updated the folder readme to include instructions for starting the vulnerability dashboard with docker
- Loading branch information
Showing
6 changed files
with
126 additions
and
1 deletion.
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,2 @@ | ||
node_modules/ | ||
npm-debug.log |
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,35 @@ | ||
# Use the official Node.js 14 image as a base | ||
FROM node:20 | ||
|
||
# Set the working directory in the container | ||
WORKDIR /usr/src/app | ||
|
||
# Copy the package.json | ||
COPY package.json ./ | ||
|
||
# Install vulnerability dashboard dependencies | ||
RUN npm install | ||
|
||
# Copy the vulnerability dashboard into the container | ||
COPY . . | ||
|
||
# Install cron on the Docker image | ||
RUN apt-get update && apt-get install -y cron | ||
|
||
# Add the crontab file for the update reports script to the cron directory | ||
ADD crontab /etc/cron.d/update-reports-cron | ||
|
||
# Give execution rights on the cron job and apply it | ||
RUN chmod 0644 /etc/cron.d/update-reports-cron && crontab /etc/cron.d/update-reports-cron | ||
|
||
# Copy the entrypoint script into the container | ||
COPY entrypoint.sh /usr/src/app/entrypoint.sh | ||
|
||
# Make sure the entrypoint script is executable | ||
RUN chmod +x /usr/src/app/entrypoint.sh | ||
|
||
# Expose the port the vulnerability dashboard runs on | ||
EXPOSE 1337 | ||
|
||
# Set the entrypoint script as the entry point | ||
ENTRYPOINT ["/usr/src/app/entrypoint.sh"] |
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 @@ | ||
0 * * * * cd /usr/src/app && /usr/local/bin/node ./node_modules/.bin/sails run update-reports >> /usr/src/app/cron.log 2>&1 |
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,31 @@ | ||
version: '3' | ||
services: | ||
vuln-dash: | ||
build: . | ||
ports: | ||
- "1337:1337" | ||
depends_on: | ||
- redis | ||
- postgres | ||
environment: | ||
sails_datastores__default__url: postgres://user:password@postgres:5432/dbname | ||
sails_datastores__default__adapter: sails-postgresql | ||
sails_sockets__url: redis://redis:6379 | ||
sails_session__url: redis://redis:6379 | ||
sails_custom__fleetBaseUrl: '' #Add the base url of your Fleet instance: ex: https://fleet.example.com | ||
sails_custom__fleetApiToken: '' # Add the API token of an API-only user [?] Here's how you get one: https://fleetdm.com/docs/using-fleet/fleetctl-cli#get-the-api-token-of-an-api-only-user | ||
|
||
redis: | ||
image: "redis:alpine" | ||
|
||
postgres: | ||
image: "postgres:alpine" | ||
environment: | ||
POSTGRES_USER: user | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_DB: dbname | ||
volumes: | ||
- pgdata:/var/lib/postgresql/data | ||
|
||
volumes: | ||
pgdata: |
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,31 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$sails_custom__fleetBaseUrl" ] && [ -z "$sails_custom__fleetApiToken" ]; then | ||
echo 'ERROR: Missing environment variables. Please set "sails_custom__fleetApiToken" and "sails_custom__fleetBaseUrl" and and try starting this container again' | ||
exit 1 | ||
elif [ -z "$sails_custom__fleetBaseUrl" ]; then | ||
echo 'ERROR: Missing environment variables. Please set "sails_custom__fleetBaseUrl" and try starting this container again' | ||
exit 1 | ||
elif [ -z "$sails_custom__fleetApiToken" ]; then | ||
echo 'ERROR: Missing environment variables. Please set "sails_custom__fleetApiToken" and and try starting this container again' | ||
exit 1 | ||
fi | ||
|
||
# Check if the vulnerability dashboard has been initialized before | ||
if [ ! -f "/usr/src/app/.initialized" ]; then | ||
# if it hasn't, lift the app with in console mode with the --drop flag to create our databsae tables. | ||
echo '.exit' | node ./node_modules/sails/bin/sails console --drop | ||
|
||
touch /usr/src/app/.initialized | ||
# run the `update-reports` script | ||
node ./node_modules/sails/bin/sails run update-reports | ||
fi | ||
|
||
# Expose the container's ENV variables to cron | ||
printenv >> /etc/environment | ||
|
||
# Start cron | ||
cron | ||
|
||
# Start the vulnerability dashboard | ||
exec node app.js |