Merge pull request #3 from ninech/docker_improvements
Docker improvements
This commit is contained in:
commit
573486f0b4
39
Dockerfile
39
Dockerfile
|
@ -1,20 +1,35 @@
|
||||||
FROM python:2.7-wheezy
|
FROM python:2.7-alpine
|
||||||
|
|
||||||
WORKDIR /opt/netbox
|
RUN apk add --no-cache \
|
||||||
|
bash \
|
||||||
|
build-base \
|
||||||
|
ca-certificates \
|
||||||
|
cyrus-sasl-dev \
|
||||||
|
graphviz \
|
||||||
|
jpeg-dev \
|
||||||
|
libffi-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
libxslt-dev \
|
||||||
|
openldap-dev \
|
||||||
|
openssl-dev \
|
||||||
|
postgresql-dev \
|
||||||
|
wget \
|
||||||
|
&& pip install gunicorn==17.5 django-auth-ldap
|
||||||
|
|
||||||
|
WORKDIR /opt
|
||||||
|
|
||||||
ARG BRANCH=v2-beta
|
ARG BRANCH=v2-beta
|
||||||
ARG URL=https://github.com/digitalocean/netbox.git
|
ARG URL=https://github.com/digitalocean/netbox/archive/$BRANCH.tar.gz
|
||||||
RUN git clone --depth 1 $URL -b $BRANCH . && \
|
RUN wget -q -O - "${URL}" | tar xz \
|
||||||
apt-get update -qq && apt-get install -y libldap2-dev libsasl2-dev libssl-dev graphviz && \
|
&& ln -s netbox* netbox
|
||||||
pip install gunicorn==17.5 && \
|
|
||||||
pip install django-auth-ldap && \
|
|
||||||
pip install -r requirements.txt
|
|
||||||
|
|
||||||
ADD docker/docker-entrypoint.sh /docker-entrypoint.sh
|
WORKDIR /opt/netbox
|
||||||
ADD netbox/netbox/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
RUN ln -s configuration.docker.py netbox/netbox/configuration.py
|
||||||
|
COPY docker/gunicorn_config.py /opt/netbox/
|
||||||
|
|
||||||
|
COPY docker/docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
ENTRYPOINT [ "/docker-entrypoint.sh" ]
|
ENTRYPOINT [ "/docker-entrypoint.sh" ]
|
||||||
|
|
||||||
ADD docker/gunicorn_config.py /opt/netbox/
|
|
||||||
ADD docker/nginx.conf /etc/netbox-nginx/
|
|
||||||
VOLUME ["/etc/netbox-nginx/"]
|
VOLUME ["/etc/netbox-nginx/"]
|
||||||
|
|
|
@ -1,53 +1,32 @@
|
||||||
version: '2'
|
version: '3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
postgres:
|
|
||||||
image: postgres:9.6
|
|
||||||
container_name: postgres
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: netbox
|
|
||||||
POSTGRES_PASSWORD: J5brHrAXFLQSif0K
|
|
||||||
POSTGRES_DB: netbox
|
|
||||||
netbox:
|
netbox:
|
||||||
build: .
|
build: .
|
||||||
image: digitalocean/netbox
|
image: digitalocean/netbox:v2.0-beta2
|
||||||
links:
|
|
||||||
- postgres
|
|
||||||
container_name: netbox
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
environment:
|
env_file: netbox.env
|
||||||
SUPERUSER_NAME: admin
|
|
||||||
SUPERUSER_EMAIL: admin@example.com
|
|
||||||
SUPERUSER_PASSWORD: admin
|
|
||||||
ALLOWED_HOSTS: localhost
|
|
||||||
DB_NAME: netbox
|
|
||||||
DB_USER: netbox
|
|
||||||
DB_PASSWORD: J5brHrAXFLQSif0K
|
|
||||||
DB_HOST: postgres
|
|
||||||
SECRET_KEY: r8OwDznj!!dci#P9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNj
|
|
||||||
EMAIL_SERVER: localhost
|
|
||||||
EMAIL_PORT: 25
|
|
||||||
EMAIL_USERNAME: foo
|
|
||||||
EMAIL_PASSWORD: bar
|
|
||||||
EMAIL_TIMEOUT: 10
|
|
||||||
EMAIL_FROM: netbox@bar.com
|
|
||||||
NETBOX_USERNAME: guest
|
|
||||||
NETBOX_PASSWORD: guest
|
|
||||||
volumes:
|
volumes:
|
||||||
|
- netbox-nginx-config:/etc/netbox-nginx/
|
||||||
- netbox-static-files:/opt/netbox/netbox/static
|
- netbox-static-files:/opt/netbox/netbox/static
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:1.11.1-alpine
|
image: nginx:1.11-alpine
|
||||||
links:
|
|
||||||
- netbox
|
|
||||||
container_name: nginx
|
|
||||||
command: nginx -g 'daemon off;' -c /etc/netbox-nginx/nginx.conf
|
command: nginx -g 'daemon off;' -c /etc/netbox-nginx/nginx.conf
|
||||||
depends_on:
|
depends_on:
|
||||||
- netbox
|
- netbox
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80
|
||||||
volumes_from:
|
volumes:
|
||||||
- netbox
|
- netbox-static-files:/opt/netbox/netbox/static
|
||||||
|
- netbox-nginx-config:/etc/netbox-nginx/
|
||||||
|
postgres:
|
||||||
|
image: postgres:9.6-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: netbox
|
||||||
|
POSTGRES_PASSWORD: J5brHrAXFLQSif0K
|
||||||
|
POSTGRES_DB: netbox
|
||||||
volumes:
|
volumes:
|
||||||
netbox-static-files:
|
netbox-static-files:
|
||||||
driver: local
|
driver: local
|
||||||
|
netbox-nginx-config:
|
||||||
|
driver: local
|
||||||
|
|
|
@ -13,7 +13,12 @@ if [[ -z ${SUPERUSER_NAME} || -z ${SUPERUSER_EMAIL} || -z ${SUPERUSER_PASSWORD}
|
||||||
SUPERUSER_PASSWORD='admin'
|
SUPERUSER_PASSWORD='admin'
|
||||||
echo "Using defaults: Username: ${SUPERUSER_NAME}, E-Mail: ${SUPERUSER_EMAIL}, Password: ${SUPERUSER_PASSWORD}"
|
echo "Using defaults: Username: ${SUPERUSER_NAME}, E-Mail: ${SUPERUSER_EMAIL}, Password: ${SUPERUSER_PASSWORD}"
|
||||||
fi
|
fi
|
||||||
echo "from django.contrib.auth.models import User; User.objects.create_superuser('${SUPERUSER_NAME}', '${SUPERUSER_EMAIL}', '${SUPERUSER_PASSWORD}')" | python /opt/netbox/netbox/manage.py shell
|
|
||||||
|
python netbox/manage.py shell --plain << END
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
if not User.objects.filter(username='${SUPERUSER_NAME}'):
|
||||||
|
User.objects.create_superuser('${SUPERUSER_NAME}', '${SUPERUSER_EMAIL}', '${SUPERUSER_PASSWORD}')
|
||||||
|
END
|
||||||
|
|
||||||
# copy static files
|
# copy static files
|
||||||
/opt/netbox/netbox/manage.py collectstatic --no-input
|
/opt/netbox/netbox/manage.py collectstatic --no-input
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
SUPERUSER_NAME=admin
|
||||||
|
SUPERUSER_EMAIL=admin@example.com
|
||||||
|
SUPERUSER_PASSWORD=admin
|
||||||
|
ALLOWED_HOSTS=localhost
|
||||||
|
DB_NAME=netbox
|
||||||
|
DB_USER=netbox
|
||||||
|
DB_PASSWORD=J5brHrAXFLQSif0K
|
||||||
|
DB_HOST=postgres
|
||||||
|
SECRET_KEY=r8OwDznj!!dci#P9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNj
|
||||||
|
EMAIL_SERVER=localhost
|
||||||
|
EMAIL_PORT=25
|
||||||
|
EMAIL_USERNAME=foo
|
||||||
|
EMAIL_PASSWORD=bar
|
||||||
|
EMAIL_TIMEOUT=10
|
||||||
|
EMAIL_FROM=netbox@bar.com
|
||||||
|
NETBOX_USERNAME=guest
|
||||||
|
NETBOX_PASSWORD=guest
|
Loading…
Reference in New Issue