Update project scaffolding

* Use nginx for static files
* Add netbox to docker-compose
* Lint source code
* Update nginx.conf to actually work
* Build a base `branch` tag for latest of that branch
This commit is contained in:
Marco Ceppi 2019-10-08 11:01:06 -04:00
parent 0c107767e3
commit 67cc069857
7 changed files with 53 additions and 21 deletions

View File

@ -71,11 +71,11 @@ spec:
*/
dir('netbox/netbox') {
sh """
cp configuration.example.py configuration.py
sed -i -e "s/ALLOWED_HOSTS = .*/ALLOWED_HOSTS = ['*']/g" configuration.py
sed -i -e "s/SECRET_KEY = .*/SECRET_KEY = 'netboxci'/g" configuration.py
sed -i -e "s/USER': .*/USER': 'netbox',/g" configuration.py
sed -i -e "s/PASSWORD': .*/PASSWORD': 'netbox',/g" configuration.py
cp configuration.example.py configuration.py
sed -i -e "s/ALLOWED_HOSTS = .*/ALLOWED_HOSTS = ['*']/g" configuration.py
sed -i -e "s/SECRET_KEY = .*/SECRET_KEY = 'netboxci'/g" configuration.py
sed -i -e "s/USER': .*/USER': 'netbox',/g" configuration.py
sed -i -e "s/PASSWORD': .*/PASSWORD': 'netbox',/g" configuration.py
"""
}
// finally, kick off tox to run the entire test suite
@ -92,8 +92,11 @@ spec:
changeRequest()
}
}
environment {
BASE_TAG = getSafeBranchName()
}
agent {
label 'docker-build'
label 'docker-build'
}
steps {
container('docker') {
@ -106,10 +109,12 @@ spec:
--build-arg BUILD_VERSION=${BUILD_TAG} \
--build-arg BRANCH=${BRANCH_NAME} \
-t ${IMAGE}:${TAG}
'''
withDockerRegistry(registry: [credentialsId: 'vio-docker-hub']) {
sh "docker push ${env.IMAGE}:${env.TAG}"
}
'''
sh 'docker tag ${IMAGE}:${TAG} ${IMAGE}:${BASE_TAG}'
withDockerRegistry(registry: [credentialsId: 'vio-docker-hub']) {
sh "docker push ${env.IMAGE}:${env.TAG}"
sh "docker push ${env.IMAGE}:${env.BASE_TAG}"
}
}
}
}

View File

@ -69,7 +69,6 @@ RUN wget -q -O - "${URL}" | tar xz \
COPY docker/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py
COPY docker/configuration/gunicorn_config.py /etc/netbox/config/
COPY docker/nginx.conf /etc/netbox-nginx/nginx.conf
COPY docker/docker-entrypoint.sh /opt/netbox/docker-entrypoint.sh
COPY docker/startup_scripts/ /opt/netbox/startup_scripts/
COPY docker/initializers/ /opt/netbox/initializers/

View File

@ -1,12 +1,38 @@
version: '2'
version: '3'
services:
postgres:
image: "postgres:9.6"
environment:
POSTGRES_PASSWORD: "12345"
POSTGRES_DB: netbox
ports:
- 5432:5432
- 5432:5432
redis:
image: "redis"
nginx:
image: "nginx"
volumes:
- "static:/opt/netbox/netbox/static"
- "./docker/nginx.conf:/etc/nginx/nginx.conf"
ports:
- 6379:6379
- 8000:80
netbox:
image: "vaporio/netbox:develop.5"
environment:
SECRET_KEY: secret
DB_HOST: postgres
DB_USER: postgres
DB_PASSWORD: "12345"
ALLOWED_HOSTS: "*"
REDIS_HOST: redis
depends_on:
- redis
- postgres
volumes:
- "./netbox:/opt/netbox/netbox"
- "static:/opt/netbox/netbox/static"
- "./docker/configuration.docker.py:/opt/netbox/netbox/netbox/configuration.py"
- "./docker/startup_scripts/:/opt/netbox/startup_scripts"
- "./docker/initializers/:/opt/netbox/initializers"
volumes:
static:

View File

@ -1,4 +1,3 @@
daemon off;
worker_processes 1;
error_log /dev/stderr info;
@ -18,7 +17,7 @@ http {
client_max_body_size 10M;
server {
listen 8080;
listen 80;
access_log off;
location /static/ {

View File

@ -408,7 +408,7 @@ SITE_ID = 1
# Django Allauth
#
ACCOUNT_DEFAULT_HTTP_PROTOCOL='https'
ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
LOGIN_REDIRECT_URL = 'home'
#

View File

@ -71,10 +71,10 @@ class VaporTestInterfaces(APITestCase):
tenant=cls.customer1,
)
cls.device2 = Device.objects.create(
name='network-locker2',
device_role=cls.devicerole1,
device_type=cls.devicetype1,
site=cls.site1,
name='network-locker2',
device_role=cls.devicerole1,
device_type=cls.devicetype1,
site=cls.site1,
)
cls.interface1 = Interface.objects.create(name='e1', device=cls.device1)
cls.interface2 = Interface.objects.create(name='xe-0/0/0', device=cls.device2)

View File

@ -8,6 +8,9 @@ description=
run tests with django.
deps=
-r{toxinidir}/requirements.txt
pycodestyle
tblib
changedir = netbox
commands=
pycodestyle --ignore=W504,E501 .
python manage.py test --failfast --noinput --parallel 5 --no-color