Skip to content
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

Update docker image #17

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
FROM tiangolo/uwsgi-nginx-flask:python3.8-alpine
FROM python:3.9-slim

COPY requirements.txt /app
RUN pip3 install -r requirements.txt
WORKDIR /app

COPY requirements.txt /app
COPY . /app

RUN pip3 install -r requirements.txt

CMD ./run.sh
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,20 @@ for ```netbox inventory``` ensure ```config.json``` has the following lines
```
configure ```"inventory_netbox.json"``` with your netbox params accordingly


### docker
to use ```docker``` you can either use the default ```config.json``` file or set some env vars:
```
export NPA_NETPALM_API_KEY=API_KEY_HERE
export NPA_NETPALM_SERVER=SERVER_HERE"
export NPA_NETPALM_PORT=PORT_HERE
export NPA_INVENTORY_FILE=INVENTORY_FILE_DIR_HERE
export NPA_INVENTORY_TYPE=INVENTORY_TYPE_HERE
```
build/run:
```
sudo docker-compose up -d --build
```

### notice
- project currently just a poc in progress, use at your own leisure
8 changes: 4 additions & 4 deletions backend/confload/confload.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import requests
import os
import os

import requests

DEFAULT_CONFIG_FILENAME = "config.json"
DEFAULT_INVENTORY_FILENAME = "inventory_local.json"
Expand Down Expand Up @@ -33,8 +33,8 @@ def __init__(self, config_filename=None, inventory_filename=None):
def get_inventory(self):
""" load the inventory """

inv_type = self.config_data.get("inventory_type")
inv_file = self.config_data.get("inventory_file")
inv_type = self.load_value("inventory_type")
inv_file = self.load_value("inventory_file")

if inv_type == "local":
if self.inventory_filename is None:
Expand Down
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
version: "3.7"
services:
netpalm-admin:
build:
context: "."
dockerfile: "Dockerfile"
image: "netpalm-admin"
container_name: "netpalm-admin"
environment:
- "PUID=1000"
- "PGID=1000"
- "TZ=UTC"
- "UMASK_SET=022"
- "NPA_NETPALM_API_KEY"
- "NPA_NETPALM_SERVER"
- "NPA_NETPALM_PORT"
- "NPA_INVENTORY_FILE"
- "NPA_INVENTORY_TYPE"
ports:
- "10001:10001"
restart: "unless-stopped"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ requests
ttp
textfsm
jinja2
gunicorn
4 changes: 4 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
gunicorn -w 4 `
`--bind 0.0.0.0:10001 `
`netpalm-admin:app --log-level debug