Compare commits
14 Commits
ce977dea8c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
6167700b86
|
|||
|
198d1749b8
|
|||
|
b13c7c6aa6
|
|||
|
94d020c9ba
|
|||
|
962d5410b1
|
|||
|
e0aa1a1ce7
|
|||
|
3bd725f6d2
|
|||
|
79840d6c13
|
|||
|
a4843430d8
|
|||
|
25704ba02e
|
|||
|
5f6eb650c8
|
|||
|
4999649c77
|
|||
|
be4fbc5eca
|
|||
|
7b9ebf426b
|
42
Dockerfile
42
Dockerfile
@@ -10,34 +10,36 @@ RUN apt update && apt upgrade -y
|
|||||||
ENV LANG en_US.UTF-8
|
ENV LANG en_US.UTF-8
|
||||||
ENV LANGUAGE en_US:en
|
ENV LANGUAGE en_US:en
|
||||||
ENV LC_ALL en_US.UTF-8
|
ENV LC_ALL en_US.UTF-8
|
||||||
RUN apt install git ca-certificates lsb-release apt-transport-https wget curl nano vim locales -y \
|
RUN apt install python-is-python3 git ca-certificates lsb-release apt-transport-https wget curl nano vim locales -y \
|
||||||
&& apt auto-remove -y \
|
&& apt auto-remove -y \
|
||||||
&& apt clean -y
|
&& apt clean -y
|
||||||
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
|
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
|
||||||
&& locale-gen
|
&& locale-gen
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
# Install Pip
|
||||||
git \
|
RUN apt install python3-pip -y
|
||||||
python3-pip \
|
|
||||||
python3-dev \
|
|
||||||
libpq-dev \
|
|
||||||
libxml2-dev \
|
|
||||||
libxslt1-dev \
|
|
||||||
libffi-dev \
|
|
||||||
libyaml-dev \
|
|
||||||
build-essential \
|
|
||||||
libssl-dev \
|
|
||||||
libpq-dev
|
|
||||||
|
|
||||||
RUN git clone https://github.com/netbox-community/netbox.git /opt/netbox
|
# clone repo
|
||||||
|
RUN git clone -b master --depth 1 https://github.com/netbox-community/netbox.git /opt/netbox
|
||||||
|
|
||||||
|
# change working dir to repo
|
||||||
WORKDIR /opt/netbox
|
WORKDIR /opt/netbox
|
||||||
|
|
||||||
RUN pip3 install --upgrade pip
|
# install requiremnets and some clean up
|
||||||
RUN pip3 install -r requirements.txt
|
RUN pip install -r requirements.txt \
|
||||||
|
&& apt-get remove -y git python3-dev build-essential libssl-dev libpq-dev \
|
||||||
|
&& apt-get autoremove -y
|
||||||
|
|
||||||
RUN apt-get remove -y git python3-dev build-essential libssl-dev libpq-dev
|
# change working dir to application
|
||||||
RUN apt-get autoremove -y
|
WORKDIR /opt/netbox/netbox
|
||||||
|
|
||||||
EXPOSE 8000
|
# Static files generation
|
||||||
CMD ["python3", "netbox/manage.py", "runserver", "0.0.0.0:8000"]
|
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
|
||||||
|
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
|
||||||
|
|||||||
56
README.md
Normal file
56
README.md
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# Netbox Docker
|
||||||
|
|
||||||
|
## Setup the service:
|
||||||
|
- Install docker or podman
|
||||||
|
- Save the following content as `docker-compose.yml`
|
||||||
|
```yaml
|
||||||
|
version: '3.5'
|
||||||
|
services:
|
||||||
|
################################################
|
||||||
|
netbox:
|
||||||
|
image: git.shihaam.dev/dockerfiles/netbox
|
||||||
|
ports:
|
||||||
|
- 8000:8000
|
||||||
|
volumes:
|
||||||
|
- ./configuration.py:/opt/netbox/netbox/netbox/configuration.py
|
||||||
|
command: python manage.py runserver 0.0.0.0:8000 --insecure # COMMENT THIS LINE AND REVERSE PROXYIN PRODUCTION !!!
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
- postgres
|
||||||
|
restart: always
|
||||||
|
################################################
|
||||||
|
postgres:
|
||||||
|
image: postgres:13-alpine
|
||||||
|
volumes:
|
||||||
|
- ./data/db:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
- POSTGRES_DB=netbox
|
||||||
|
- POSTGRES_USER=netbox
|
||||||
|
- POSTGRES_PASSWORD=netbox # CHANGE THIS IN PRODUCTION !!
|
||||||
|
restart: always
|
||||||
|
################################################
|
||||||
|
redis:
|
||||||
|
image: redis:6.0-alpine
|
||||||
|
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`
|
||||||
|
|
||||||
|
## PLEASE, FOR THE LOVE OF GOD PLEASE DO NOT USE PASSWORD I GAVE IN THIS REPO IN PRODUCTION !!
|
||||||
|
|
||||||
|
## Some commands that will be useful
|
||||||
|
- Migrate Database (required on initial install and upgrade
|
||||||
|
```bash
|
||||||
|
docker compose exec netbox ./manage.py migrate
|
||||||
|
```
|
||||||
|
- Create new Superuser account, (it might not show any output, just enter a username and press enter)
|
||||||
|
```bash
|
||||||
|
docker compose exec netbox ./manage.py createsuperuser
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user