|
1 | | -### Initial Setup |
| 1 | +# Setup Guide |
2 | 2 |
|
3 | | -1. Prepare the web client with the following steps: |
| 3 | +This guide walks you through setting up GeoInsight for local development using Docker Compose. |
4 | 4 |
|
5 | | - 1. Run `cp web/.env.example web/.env`. |
6 | | - 2. Install client dependencies by running `cd web && npm i`. |
| 5 | +## Prerequisites |
7 | 6 |
|
8 | | -2. Run the docker containers with `docker compose up`. Be sure to check that all containers were able to start and stay running successfully before continuing. |
9 | | -3. While the containers are up, run the following commands in a separate terminal to prepare the database: |
| 7 | +- [Docker](https://docs.docker.com/get-docker/) (v20.10+) |
| 8 | +- [Docker Compose](https://docs.docker.com/compose/install/) (v2.0+) |
| 9 | +- [Node.js](https://nodejs.org/) (v22+ recommended) |
| 10 | +- [npm](https://www.npmjs.com/) |
10 | 11 |
|
11 | | - a. Run `docker compose run --rm django ./manage.py migrate`. |
| 12 | +--- |
12 | 13 |
|
13 | | - b. Run `docker compose run --rm django ./manage.py createsuperuser` |
14 | | - and follow the prompts to create your own user. |
| 14 | +## Initial Setup |
15 | 15 |
|
16 | | - c. Run `docker compose run --rm django ./manage.py makeclient` to create a client Application object for authentication. |
| 16 | +### 1. Prepare the Web Client |
17 | 17 |
|
18 | | - d. Run `docker compose run --rm django ./manage.py ingest {JSON file}` to use sample data. |
| 18 | +```bash |
| 19 | +# Copy environment configuration |
| 20 | +cp web/.env.example web/.env |
| 21 | +``` |
19 | 22 |
|
20 | | - - The JSON file can either be `multiframe_test.json`, `boston_floods.json`, `la_wildfires.json` or `./new_york_energy/data.json` |
| 23 | +### 2. Build and Start Docker Containers |
21 | 24 |
|
22 | | -### Run Application |
| 25 | +```bash |
| 26 | +docker compose build |
| 27 | +docker compose up |
| 28 | +``` |
23 | 29 |
|
24 | | -1. Run `docker compose up`. |
25 | | -2. You can access the admin page at port 8000: http://localhost:8000/admin/ |
26 | | -3. The user interface is on port **8080**: http://localhost:8080/ |
27 | | -4. When finished, use `Ctrl+C` to stop the docker compose command. |
| 30 | +> **Note:** Ensure all containers start and stay running before continuing. Check the logs for any errors. |
28 | 31 |
|
29 | | -### Application Maintenance |
| 32 | +### 3. Initialize the Database |
30 | 33 |
|
31 | | -Occasionally, new package dependencies or schema changes will necessitate |
32 | | -maintenance. To non-destructively update your development stack at any time: |
| 34 | +While the containers are running, open a **separate terminal** and run: |
33 | 35 |
|
34 | | -1. Run `docker compose pull` |
35 | | -2. Run `docker compose build --pull --no-cache` |
36 | | -3. Run `docker compose run --rm django ./manage.py migrate` |
| 36 | +```bash |
| 37 | +# Apply database migrations |
| 38 | +docker compose run --rm django python manage.py migrate |
| 39 | + |
| 40 | +# Create an admin user (you will be prompted for email and password) |
| 41 | +docker compose run --rm -it django python manage.py createsuperuser |
| 42 | + |
| 43 | +# Create OAuth client for authentication |
| 44 | +docker compose run --rm django python manage.py makeclient |
| 45 | +``` |
| 46 | + |
| 47 | +> **Note:** The `createsuperuser` command prompts you to create login credentials (email and password). Use these credentials to sign into both the Admin Panel and User Interface. If you forget your password, run `createsuperuser` again to create a new admin account. |
| 48 | +
|
| 49 | +> **Windows Users:** If the `createsuperuser` command hangs or doesn't show prompts, prefix the command with `winpty`: |
| 50 | +> ```bash |
| 51 | +> winpty docker compose run --rm -it django python manage.py createsuperuser |
| 52 | +> ``` |
| 53 | +
|
| 54 | +### 4. Load Sample Data (Optional) |
| 55 | +
|
| 56 | +The ingest command loads datasets, charts, and project configuration from an ingestion file: |
| 57 | +
|
| 58 | +```bash |
| 59 | +docker compose run --rm django python manage.py ingest {JSON_FILE} |
| 60 | +``` |
| 61 | +
|
| 62 | +Available ingest options (paths relative to `sample_data/`): |
| 63 | +- `multiframe_test.json` |
| 64 | +- `boston_floods.json` |
| 65 | +- `la_wildfires.json` |
| 66 | +- `new_york_energy/data.json` |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## Running the Application |
| 71 | + |
| 72 | +### Start the Services |
| 73 | + |
| 74 | +**Default (CPU-only):** |
| 75 | +```bash |
| 76 | +docker compose up |
| 77 | +``` |
| 78 | + |
| 79 | +**With GPU acceleration (NVIDIA systems only):** |
| 80 | +```bash |
| 81 | +docker compose --profile gpu up --scale celery=0 |
| 82 | +``` |
| 83 | + |
| 84 | +> **Note:** GPU mode requires NVIDIA drivers and [nvidia-docker](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html) runtime. |
| 85 | +
|
| 86 | +### Access Points |
| 87 | + |
| 88 | +| Service | URL | |
| 89 | +|---------|-----| |
| 90 | +| User Interface | http://localhost:8080/ | |
| 91 | +| Admin Panel | http://localhost:8000/admin/ | |
| 92 | +| API Documentation | http://localhost:8000/api/docs/swagger/ | |
| 93 | + |
| 94 | +Log in using the credentials you created with `createsuperuser`. |
| 95 | + |
| 96 | +### Stop the Services |
| 97 | + |
| 98 | +Press `Ctrl+C` in the terminal running `docker compose up`, or run: |
| 99 | + |
| 100 | +```bash |
| 101 | +docker compose stop |
| 102 | +``` |
| 103 | + |
| 104 | +--- |
| 105 | + |
| 106 | +## Application Maintenance |
| 107 | + |
| 108 | +When new package dependencies or database schema changes occur, update your development environment: |
| 109 | + |
| 110 | +```bash |
| 111 | +# Pull latest base images |
| 112 | +docker compose pull |
| 113 | + |
| 114 | +# Rebuild containers (no cache) |
| 115 | +docker compose build --pull --no-cache |
| 116 | + |
| 117 | +# Apply any new migrations |
| 118 | +docker compose run --rm django python manage.py migrate |
| 119 | +``` |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +## Troubleshooting |
| 124 | + |
| 125 | +### Container Build Failures |
| 126 | + |
| 127 | +If you encounter build errors related to Python packages: |
| 128 | + |
| 129 | +1. **Clear Docker build cache:** |
| 130 | + ```bash |
| 131 | + docker compose build --no-cache |
| 132 | + ``` |
| 133 | + |
| 134 | +2. **Prune unused Docker resources:** |
| 135 | + ```bash |
| 136 | + docker system prune -a |
| 137 | + ``` |
| 138 | + |
| 139 | +### Database Connection Issues |
| 140 | + |
| 141 | +Ensure PostgreSQL is running and healthy: |
| 142 | + |
| 143 | +```bash |
| 144 | +docker compose ps |
| 145 | +docker compose logs postgres |
| 146 | +``` |
| 147 | + |
| 148 | +### Port Conflicts |
| 149 | + |
| 150 | +If ports 8000, 8080, 5432, or 9000 are in use, modify the port mappings in `docker-compose.override.yml`. |
| 151 | + |
| 152 | +### GPU Not Available |
| 153 | + |
| 154 | +If you see an error like: |
| 155 | +``` |
| 156 | +Error response from daemon: could not select device driver "nvidia" with capabilities: [[gpu]] |
| 157 | +``` |
| 158 | + |
| 159 | +This means GPU mode was requested but NVIDIA drivers aren't available. Use the default CPU mode instead: |
| 160 | +```bash |
| 161 | +docker compose up |
| 162 | +``` |
| 163 | + |
| 164 | +GPU acceleration is optional and only needed for accelerated inferencing. |
| 165 | + |
| 166 | +### Windows-Specific Issues |
| 167 | + |
| 168 | +**Interactive commands don't work or hang:** |
| 169 | + |
| 170 | +On Windows (especially Git Bash/MINGW), interactive Docker commands like `createsuperuser` may hang or fail to display prompts. Prefix the command with `winpty`: |
| 171 | + |
| 172 | +```bash |
| 173 | +winpty docker compose run --rm -it django python manage.py createsuperuser |
| 174 | +``` |
| 175 | + |
| 176 | +**"No such container" errors:** |
| 177 | + |
| 178 | +If you see errors like `No such container: django` when trying to attach to a running container, use `docker compose run` instead: |
| 179 | + |
| 180 | +```bash |
| 181 | +docker compose run --rm -it django python manage.py <command> |
| 182 | +``` |
| 183 | + |
| 184 | +This creates a new container instance rather than attaching to an existing one. |
0 commit comments