Skip to content

Commit 569963d

Browse files
authored
Merge pull request #243 from OpenGeoscience/fix/docker-cross-platform-support
Fix Docker build and runtime issues for cross-platform support
2 parents 9548534 + 56e8063 commit 569963d

File tree

5 files changed

+222
-30
lines changed

5 files changed

+222
-30
lines changed

dev/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ FROM python:3.11-slim
22
# Install system libraries for Python packages:
33
RUN apt-get update && \
44
apt-get install --no-install-recommends --yes \
5-
libpq-dev libvips-dev gcc libc6-dev gdal-bin git libgl1 libglx-mesa0 && \
5+
libpq-dev libvips-dev gcc g++ libc6-dev gdal-bin libgdal-dev git libgl1 libglx-mesa0 && \
66
rm -rf /var/lib/apt/lists/*
77

88
ENV PYTHONDONTWRITEBYTECODE=1
99
ENV PYTHONUNBUFFERED=1
10+
# Use system gdal-config instead of Python GDAL's version (which requires osgeo module)
11+
ENV GDAL_CONFIG=/usr/bin/gdal-config
1012

1113
ARG TASKS
1214

docker-compose.override.yml

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33
build:
44
context: .
55
dockerfile: ./dev/Dockerfile
6-
command: ["./manage.py", "runserver", "0.0.0.0:8000"]
6+
command: ["python", "manage.py", "runserver", "0.0.0.0:8000"]
77
# Log printing via Rich is enhanced by a TTY
88
tty: true
99
env_file: ./dev/.env.docker-compose
@@ -21,6 +21,7 @@ services:
2121
- rabbitmq
2222
- minio
2323

24+
# Default celery worker (CPU-only, runs by default)
2425
celery:
2526
build:
2627
context: .
@@ -49,12 +50,54 @@ services:
4950
- rabbitmq
5051
- minio
5152

53+
# GPU-enabled celery worker for accelerated inferencing
54+
# Use with: docker compose --profile gpu up --scale celery=0
55+
celery-gpu:
56+
build:
57+
context: .
58+
dockerfile: ./dev/Dockerfile
59+
args:
60+
TASKS: 1
61+
command:
62+
[
63+
"celery",
64+
"--app",
65+
"geoinsight.celery",
66+
"worker",
67+
"--loglevel",
68+
"INFO",
69+
"--without-heartbeat",
70+
]
71+
tty: false
72+
environment:
73+
- DJANGO_HOMEPAGE_REDIRECT_URL=http://localhost:8080/
74+
env_file: ./dev/.env.docker-compose
75+
volumes:
76+
- .:/opt/geoinsight-server
77+
shm_size: 1gb
78+
profiles: ["gpu"] # Only runs with --profile gpu
79+
deploy:
80+
resources:
81+
reservations:
82+
devices:
83+
- driver: nvidia
84+
count: 1
85+
capabilities: [gpu]
86+
depends_on:
87+
- postgres
88+
- rabbitmq
89+
- minio
90+
5291
web:
53-
image: node:latest
54-
command: ["npm", "run", "serve"]
92+
image: node:22
93+
command: ["sh", "-c", "npm install && npm run serve"]
5594
working_dir: /web
5695
volumes:
5796
- ./web:/web
5897
- ./.git:/web/.git # allow fetching version tag
98+
- web_node_modules:/web/node_modules # Keep container's node_modules separate from host
5999
ports:
60100
- 8080:8080
101+
102+
volumes:
103+
web_node_modules:

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: "3"
21
services:
32
postgres:
43
image: postgis/postgis:14-3.3
@@ -53,4 +52,4 @@ volumes:
5352
postgres:
5453
minio:
5554
rabbitmq:
56-
redis-data:
55+
redis-data:

docs/setup.md

Lines changed: 171 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,184 @@
1-
### Initial Setup
1+
# Setup Guide
22

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.
44

5-
1. Run `cp web/.env.example web/.env`.
6-
2. Install client dependencies by running `cd web && npm i`.
5+
## Prerequisites
76

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/)
1011

11-
a. Run `docker compose run --rm django ./manage.py migrate`.
12+
---
1213

13-
b. Run `docker compose run --rm django ./manage.py createsuperuser`
14-
and follow the prompts to create your own user.
14+
## Initial Setup
1515

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
1717

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+
```
1922

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
2124

22-
### Run Application
25+
```bash
26+
docker compose build
27+
docker compose up
28+
```
2329

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.
2831
29-
### Application Maintenance
32+
### 3. Initialize the Database
3033

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:
3335

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.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
'pooch[progress]==1.8.2',
6464
'psycopg[pool]',
6565
'pyshp==2.3.1',
66-
'rasterio==1.3.10',
66+
'rasterio==1.3.11',
6767
'urllib3==1.26.15',
6868
'webcolors==24.6.0',
6969
# Production only

0 commit comments

Comments
 (0)