-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Docker support, set hardcoded values to ENV variables #1
Open
dky
wants to merge
2
commits into
candlerb:master
Choose a base branch
from
dky:feature/docker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,19 @@ | ||
FROM debian:bullseye-slim | ||
|
||
RUN apt-get update && apt-get -y install supervisor nginx python3-pip procps | ||
|
||
COPY netbox_prometheus.py /netbox_prometheus.py | ||
COPY requirements.txt /requirements.txt | ||
|
||
ADD conf/default.conf /etc/nginx/sites-enabled/default | ||
ADD poll.sh / | ||
|
||
COPY conf/supervisord.conf /etc/supervisor/conf.d/supervisord.conf | ||
|
||
RUN pip3 install -r /requirements.txt \ | ||
&& chmod +x /netbox_prometheus.py \ | ||
&& mkdir -p /etc/prometheus/targets.d /var/www/html/metrics \ | ||
&& chmod +x /poll.sh | ||
|
||
EXPOSE 80 | ||
CMD ["/usr/bin/supervisord"] |
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,10 @@ | ||
# Default Nginx endpoint to expose metrics | ||
server { | ||
server_name _; | ||
listen *:80 default_server deferred; | ||
location / { | ||
add_header Content-Type text/plain; | ||
root /var/www/html; | ||
} | ||
|
||
} |
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,21 @@ | ||
[supervisord] | ||
nodaemon=true | ||
|
||
[program:nginx] | ||
command=/usr/sbin/nginx -g "daemon off;" | ||
priority=900 | ||
stdout_logfile= /dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stderr | ||
stderr_logfile_maxbytes=0 | ||
username=www-data | ||
autorestart=true | ||
|
||
[program:netbox_prometheus] | ||
directory=/ | ||
command=/poll.sh | ||
stdout_logfile= /dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stderr | ||
stderr_logfile_maxbytes=0 | ||
autostart=true |
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,8 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
# Sleep interval for how often to poll (300s) This can be controlled by setting SLEEP_INT env var. | ||
sleep_duration="${SLEEP_INT:-300}" | ||
|
||
while true; do (python3 netbox_prometheus.py; sleep $sleep_duration); done | ||
|
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 @@ | ||
pynetbox | ||
pyyaml |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICS, this is true by default (which is what I'd expect):
However, I guess it's useful to have it as documentation on how to disable HTTPS verification if required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, we had a bit of an issue when we started playing with this with one of our internally signed certificates. Python request just did not like it so I was digging around to figure out how to disable it. So I found that. The plan was to set another ENV var and set it to true by default for us to disable but I couldn't get it to work. So I just left it True in the commit so I could toggle it off in our internal environment. Getting an ENV variable such as SSL_VALIDATE would be ideal.