Compare commits

...

12 Commits

2 changed files with 24 additions and 7 deletions

View File

@@ -20,7 +20,7 @@ RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
RUN apt install python3-pip -y RUN apt install python3-pip -y
# clone repo # clone repo
RUN git clone https://github.com/netbox-community/netbox.git /opt/netbox RUN git clone -b master --depth 1 https://github.com/netbox-community/netbox.git /opt/netbox
# change working dir to repo # change working dir to repo
WORKDIR /opt/netbox WORKDIR /opt/netbox
@@ -33,5 +33,13 @@ RUN pip install -r requirements.txt \
# change working dir to application # change working dir to application
WORKDIR /opt/netbox/netbox WORKDIR /opt/netbox/netbox
# Static files generation
RUN cp netbox/configuration_example.py netbox/configuration.py \
&& python manage.py collectstatic --no-input \
&& rm netbox/configuration.py
# Web server setup
RUN cp /opt/netbox/contrib/gunicorn.py /opt/netbox/gunicorn.py
# run the service # run the service
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

View File

@@ -1,7 +1,8 @@
# Netbox Docker
## Setup the service:
- Production `docker-compose.yml` - Install docker or podman
- Save the following content as `docker-compose.yml`
```yaml ```yaml
version: '3.5' version: '3.5'
services: services:
@@ -12,10 +13,11 @@ services:
- 8000:8000 - 8000:8000
volumes: volumes:
- ./configuration.py:/opt/netbox/netbox/netbox/configuration.py - ./configuration.py:/opt/netbox/netbox/netbox/configuration.py
command: python manage.py runserver 0.0.0.0:8000 --insecure # COMMENT THIS LINE WHEN RUNNING IN PRODUCTION command: python manage.py runserver 0.0.0.0:8000 --insecure # COMMENT THIS LINE AND REVERSE PROXYIN PRODUCTION !!!
depends_on: depends_on:
- redis - redis
- postgres - postgres
restart: always
################################################ ################################################
postgres: postgres:
image: postgres:13-alpine image: postgres:13-alpine
@@ -24,15 +26,22 @@ services:
environment: environment:
- POSTGRES_DB=netbox - POSTGRES_DB=netbox
- POSTGRES_USER=netbox - POSTGRES_USER=netbox
- POSTGRES_PASSWORD=even-confider-closable - POSTGRES_PASSWORD=netbox # CHANGE THIS IN PRODUCTION !!
restart: always restart: always
################################################ ################################################
redis: redis:
image: redis:6.0-alpine image: redis:6.0-alpine
restart: always restart: always
``` ```
- Fetch example config from container `docker compose run --rm netbox cat /opt/netbox/netbox/netbox/configuration_example.py > configuration.py` and edit it according to your enviroment.
- Create `devicetype-images` and `image-attachments` folders under media folder
```bash
mkdir -p media/image-attachments media/devicetype-images
```
- Generate Secret key `docker compose run --rm netbox ./generate_secret_key.py`, add output of this to configuration.py
- Run `docker compose up -d`
- save this as docker-compose.yml and run `docker compose up -d` ## PLEASE, FOR THE LOVE OF GOD PLEASE DO NOT USE PASSWORD I GAVE IN THIS REPO IN PRODUCTION !!
## Some commands that will be useful ## Some commands that will be useful
- Migrate Database (required on initial install and upgrade - Migrate Database (required on initial install and upgrade