Skip to content

Commit 0ec30df

Browse files
committed
Split out Docker commands for better readability
1 parent a40ecdd commit 0ec30df

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

‎README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,32 @@ First, drop and recreate the PostgreSQL database. The example here assumes the d
1515
```bash
1616
sudo -u postgres psql -c "DROP database netbox;"
1717
sudo -u postgres psql -c "CREATE database netbox;"
18-
19-
# NetBox Docker
20-
docker-compose exec postgres sh -c 'psql -U $POSTGRES_USER postgres -c "DROP DATABASE netbox;"'
21-
docker-compose exec postgres sh -c 'psql -U $POSTGRES_USER postgres -c "CREATE DATABASE netbox;"'
2218
```
2319

2420
Next, apply NetBox's database migrations using the `migrate` management command. (Ensure that the Python virtual environment is active before attempting to invoke the command.)
2521

2622
```bash
2723
source /opt/netbox/venv/bin/activate
2824
./manage.py migrate
29-
30-
# Netbox Docker
31-
docker-compose exec netbox bash -c "source /opt/netbox/venv/bin/activate && ./manage.py migrate"
3225
```
3326

3427
Finally, load the demo data fixtures from the JSON file.
3528

3629
```bash
3730
./manage.py loaddata -v 3 netbox-demo-$VERSION.json
31+
```
32+
33+
### Docker Commands
34+
35+
```
36+
# Drop & recreate the database
37+
docker-compose exec postgres sh -c 'psql -U $POSTGRES_USER postgres -c "DROP DATABASE netbox;"'
38+
docker-compose exec postgres sh -c 'psql -U $POSTGRES_USER postgres -c "CREATE DATABASE netbox;"'
39+
40+
# Apply migrations
41+
docker-compose exec netbox bash -c "source /opt/netbox/venv/bin/activate && ./manage.py migrate"
3842
39-
# NetBox Docker
43+
# Load the demo data
4044
docker cp netbox-demo-$VERSION.json "$(docker-compose ps -q netbox)":/opt/netbox/netbox/netbox-demo.json
4145
docker-compose exec netbox bash -c "source /opt/netbox/venv/bin/activate && ./manage.py loaddata netbox-demo.json"
4246
```
@@ -48,8 +52,11 @@ The following steps are necessary **only** if you intend to save a snapshot of d
4852
```bash
4953
source /opt/netbox/venv/bin/activate
5054
./manage.py dumpdata --natural-foreign --natural-primary -e extras.Script -e extras.Report -e extras.ObjectChange -e django_rq --indent 2 -o netbox-demo-$VERSION.json
55+
```
5156

52-
# NetBox Docker
57+
### Docker Commands
58+
59+
```
5360
docker-compose exec netbox bash -c "source /opt/netbox/venv/bin/activate && ./manage.py dumpdata --natural-foreign --natural-primary -e extras.Script -e extras.Report -e extras.ObjectChange --indent 2" > netbox-demo-$VERSION.json
5461
```
5562

0 commit comments

Comments
 (0)