commit
dd5da7afbc
13
Dockerfile
13
Dockerfile
|
@ -13,12 +13,13 @@ RUN apk add --no-cache \
|
||||||
openldap-dev \
|
openldap-dev \
|
||||||
openssl-dev \
|
openssl-dev \
|
||||||
postgresql-dev \
|
postgresql-dev \
|
||||||
wget \
|
wget
|
||||||
&& pip install gunicorn==17.5
|
|
||||||
|
RUN pip install gunicorn
|
||||||
|
|
||||||
WORKDIR /opt
|
WORKDIR /opt
|
||||||
|
|
||||||
ARG BRANCH=v2.0.7
|
ARG BRANCH=master
|
||||||
ARG URL=https://github.com/digitalocean/netbox/archive/$BRANCH.tar.gz
|
ARG URL=https://github.com/digitalocean/netbox/archive/$BRANCH.tar.gz
|
||||||
RUN wget -q -O - "${URL}" | tar xz \
|
RUN wget -q -O - "${URL}" | tar xz \
|
||||||
&& mv netbox* netbox
|
&& mv netbox* netbox
|
||||||
|
@ -26,11 +27,15 @@ RUN wget -q -O - "${URL}" | tar xz \
|
||||||
WORKDIR /opt/netbox
|
WORKDIR /opt/netbox
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
RUN ln -s configuration.docker.py netbox/netbox/configuration.py
|
RUN ln -s configuration.docker.py /opt/netbox/netbox/netbox/configuration.py
|
||||||
COPY docker/gunicorn_config.py /opt/netbox/
|
COPY docker/gunicorn_config.py /opt/netbox/
|
||||||
COPY docker/nginx.conf /etc/netbox-nginx/nginx.conf
|
COPY docker/nginx.conf /etc/netbox-nginx/nginx.conf
|
||||||
|
|
||||||
|
WORKDIR /opt/netbox/netbox
|
||||||
|
|
||||||
COPY docker/docker-entrypoint.sh /docker-entrypoint.sh
|
COPY docker/docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
ENTRYPOINT [ "/docker-entrypoint.sh" ]
|
ENTRYPOINT [ "/docker-entrypoint.sh" ]
|
||||||
|
|
||||||
VOLUME ["/etc/netbox-nginx/"]
|
VOLUME ["/etc/netbox-nginx/"]
|
||||||
|
|
||||||
|
CMD ["gunicorn", "--log-level debug", "-c /opt/netbox/gunicorn_config.py", "netbox.wsgi"]
|
||||||
|
|
|
@ -51,3 +51,11 @@ You can configure the app at runtime using variables (see `docker-compose.yml`).
|
||||||
* SHORT_TIME_FORMAT
|
* SHORT_TIME_FORMAT
|
||||||
* DATETIME_FORMAT
|
* DATETIME_FORMAT
|
||||||
* SHORT_DATETIME_FORMAT
|
* SHORT_DATETIME_FORMAT
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
|
||||||
|
To run the bundled test, use the `docker-compose.test.yml` file.
|
||||||
|
|
||||||
|
```
|
||||||
|
# docker-compose -f docker-compose.test.yml run --rm app
|
||||||
|
```
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
args:
|
||||||
|
- BRANCH=${BRANCH-master}
|
||||||
|
image: ninech/netbox:${BRANCH-latest}
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
env_file: netbox.env
|
||||||
|
command:
|
||||||
|
- ./manage.py
|
||||||
|
- test
|
||||||
|
postgres:
|
||||||
|
image: postgres:9.6-alpine
|
||||||
|
env_file: postgres.env
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
netbox-static-files:
|
||||||
|
driver: local
|
||||||
|
netbox-nginx-config:
|
||||||
|
driver: local
|
|
@ -5,7 +5,7 @@ services:
|
||||||
context: .
|
context: .
|
||||||
args:
|
args:
|
||||||
- BRANCH=${BRANCH-master}
|
- BRANCH=${BRANCH-master}
|
||||||
image: ninech/netbox:${BRANCH-master}
|
image: ninech/netbox:${BRANCH-latest}
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
env_file: netbox.env
|
env_file: netbox.env
|
||||||
|
@ -24,10 +24,8 @@ services:
|
||||||
- netbox-nginx-config:/etc/netbox-nginx/
|
- netbox-nginx-config:/etc/netbox-nginx/
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:9.6-alpine
|
image: postgres:9.6-alpine
|
||||||
environment:
|
env_file: postgres.env
|
||||||
POSTGRES_USER: netbox
|
|
||||||
POSTGRES_PASSWORD: J5brHrAXFLQSif0K
|
|
||||||
POSTGRES_DB: netbox
|
|
||||||
volumes:
|
volumes:
|
||||||
netbox-static-files:
|
netbox-static-files:
|
||||||
driver: local
|
driver: local
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# run db migrations (retry on error)
|
# run db migrations (retry on error)
|
||||||
while ! /opt/netbox/netbox/manage.py migrate 2>&1; do
|
while ! ./manage.py migrate 2>&1; do
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -14,14 +14,17 @@ if [[ -z ${SUPERUSER_NAME} || -z ${SUPERUSER_EMAIL} || -z ${SUPERUSER_PASSWORD}
|
||||||
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
|
||||||
|
|
||||||
python netbox/manage.py shell --plain << END
|
./manage.py shell --plain << END
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
if not User.objects.filter(username='${SUPERUSER_NAME}'):
|
if not User.objects.filter(username='${SUPERUSER_NAME}'):
|
||||||
User.objects.create_superuser('${SUPERUSER_NAME}', '${SUPERUSER_EMAIL}', '${SUPERUSER_PASSWORD}')
|
User.objects.create_superuser('${SUPERUSER_NAME}', '${SUPERUSER_EMAIL}', '${SUPERUSER_PASSWORD}')
|
||||||
END
|
END
|
||||||
|
|
||||||
# copy static files
|
# copy static files
|
||||||
/opt/netbox/netbox/manage.py collectstatic --no-input
|
./manage.py collectstatic --no-input
|
||||||
|
|
||||||
# start unicorn
|
echo "✅ Initialisation is done. Launching CMD:"
|
||||||
gunicorn --log-level debug --debug -c /opt/netbox/gunicorn_config.py netbox.wsgi
|
echo "exec ${@}"
|
||||||
|
|
||||||
|
# launch whatever is passed by docker via RUN
|
||||||
|
exec ${@}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
POSTGRES_USER=netbox
|
||||||
|
POSTGRES_PASSWORD=J5brHrAXFLQSif0K
|
||||||
|
POSTGRES_DB=netbox
|
Loading…
Reference in New Issue