You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add a Docker Compose setup.
* Make app and docs ports configurable.
* Add .dockerignore.
* Wait for postgres in app container.
* Run app container in /app.
* Add docs to contributing.
* Add settings.LOGIN_URL.
* Make GID, UID customizable and document it.
* Move LOGIN_URL to settings.py.
* Add redirect from / to /dashboard/.
* Auto-run migrations on 'docker compose up'.
Thanks, Atul Varma
Copy file name to clipboardExpand all lines: docs/contributing.md
+95Lines changed: 95 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,3 +42,98 @@ To build the documentation locally, run the following:
42
42
make livehtml
43
43
44
44
This will start a live preview server, using [sphinx-autobuild](https://pypi.org/project/sphinx-autobuild/).
45
+
46
+
## Using Docker Compose
47
+
48
+
If you're familiar with Docker--or even if you're not--you may want to consider using our optional Docker Compose setup.
49
+
50
+
An advantage of this approach is that it relieves you of setting up any dependencies, such as ensuring that you have the proper version of Python and Postgres and so forth. On the downside, however, it does require you to familiarize yourself with Docker, which, while relatively easy to use, still has its own learning curve.
51
+
52
+
To try out the Docker Compose setup, you will first want to [get Docker][] and [install Docker Compose][].
53
+
54
+
Then, after checking out the code, run the following:
55
+
56
+
```
57
+
cd django-sql-dashboard
58
+
docker-compose build
59
+
```
60
+
61
+
At this point, you can start editing code. To run any development tools such as `pytest` or `black`, just prefix everything with `docker-compose run app`. For instance, to run the test suite, run:
62
+
63
+
```
64
+
docker-compose run app python pytest
65
+
```
66
+
67
+
If this is a hassle, you can instead run a bash shell inside your container:
68
+
69
+
```
70
+
docker-compose run app bash
71
+
```
72
+
73
+
At this point, you'll be in a bash shell inside your container, and can run development tools directly.
The Docker Compose setup is configured to run a simple test project that you can use to tinker with the dashboard interactively.
81
+
82
+
To use it, run:
83
+
84
+
```
85
+
docker-compose up
86
+
```
87
+
88
+
Then, in a separate terminal, run:
89
+
90
+
```
91
+
docker-compose run app python test_project/manage.py createsuperuser
92
+
```
93
+
94
+
You will now be prompted to enter details about a new superuser. Once you've done that, you can visit the example app's dashboard at http://localhost:8000/. After entering the credentials for the superuser you just created, you will be able to tinker with the dashboard.
95
+
96
+
### Editing the documentation
97
+
98
+
Running `docker-compose up` also starts the documentation system's live preview server. You can visit it at http://localhost:8001/.
99
+
100
+
### Changing the default ports
101
+
102
+
If you are already using ports 8000 and/or 8001 for other things, you can change them. To do this, create a file in the repository root called `.env` and populate it with the following:
103
+
104
+
```
105
+
APP_PORT=9000
106
+
DOCS_PORT=9001
107
+
```
108
+
109
+
You can change the above port values to whatever makes sense for your setup.
110
+
111
+
Once you next run `docker-compose up` again, the services will be running on the ports you specified in `.env`.
112
+
113
+
### Changing the default UID and GID
114
+
115
+
The default settings assume that the user id (UID) and group id (GID) of the account you're using to develop are both 1000. This is likely to be the case, since that's the UID/GID of the first non-root account on most systems. However, if your account doesn't match this, you can customize the container to use a different UID/GID.
116
+
117
+
For instance, if your UID and GID are 1001, you can build your container with the following arguments:
The project's Python dependencies are all baked into the container image, which means that whenever they change (or to be safe, whenever you `git pull` new changes to the codebase), you will want to run:
126
+
127
+
```
128
+
docker-compose build
129
+
```
130
+
131
+
You will also want to restart `docker-compose up`.
132
+
133
+
### Cleaning up
134
+
135
+
If you somehow get your Docker Compose setup into a broken state, or you decide that you never use Docker Compose again, you can clean everything up by running:
0 commit comments