|
| 1 | +# HydroServer Deployment with Docker Compose |
| 2 | + |
| 3 | +This guide describes how to deploy **HydroServer** using Docker Compose. |
| 4 | +HydroServer releases are distributed as Docker images via [GitHub Container Registry (GHCR)](https://ghcr.io). |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## Prerequisites |
| 9 | + |
| 10 | +Before you begin, ensure you have the following installed: |
| 11 | + |
| 12 | +- [Docker](https://docs.docker.com/get-docker/) |
| 13 | +- [Docker Compose](https://docs.docker.com/compose/install/) |
| 14 | + |
| 15 | +## Docker Compose Setup |
| 16 | + |
| 17 | +Below is a minimal `docker-compose.yml` example that will help you get started with a HydroServer deployment. |
| 18 | + |
| 19 | +- Note: This example is intended to get you started, but is not ready to run. You should extend and modify this configuration as needed. |
| 20 | + |
| 21 | +```yaml |
| 22 | +services: |
| 23 | + hydroserver-base: &hydroserver_base |
| 24 | + image: ghcr.io/hydroserver2/hydroserver-api-services:latest |
| 25 | + environment: |
| 26 | + PROXY_BASE_URL: https://hydroserver.example.com |
| 27 | + SECRET_KEY: changeme |
| 28 | + DATABASE_URL: postgres://hydroserver:changeme@database:5432/hydroserver |
| 29 | + volumes: |
| 30 | + - static:/app/static |
| 31 | + - media:/app/media |
| 32 | + |
| 33 | + hydroserver-web: |
| 34 | + <<: *hydroserver_base |
| 35 | + restart: unless-stopped |
| 36 | + ports: |
| 37 | + - "8000:8000" |
| 38 | + depends_on: |
| 39 | + database: |
| 40 | + condition: service_healthy |
| 41 | + hydroserver-init: |
| 42 | + condition: service_completed_successfully |
| 43 | + command: > |
| 44 | + sh -c "gunicorn --bind 0.0.0.0:8000 --workers 3 hydroserver.wsgi:application" |
| 45 | + |
| 46 | + hydroserver-init: |
| 47 | + <<: *hydroserver_base |
| 48 | + depends_on: |
| 49 | + database: |
| 50 | + condition: service_healthy |
| 51 | + command: > |
| 52 | + sh -c "python manage.py migrate && |
| 53 | + python manage.py setup_admin_user && |
| 54 | + python manage.py load_default_data && |
| 55 | + python manage.py collectstatic --noinput" |
| 56 | + restart: "no" |
| 57 | + |
| 58 | + database: |
| 59 | + image: postgres:17 |
| 60 | + restart: unless-stopped |
| 61 | + environment: |
| 62 | + POSTGRES_DB: hydroserver |
| 63 | + POSTGRES_USER: hydroserver |
| 64 | + POSTGRES_PASSWORD: changeme |
| 65 | + volumes: |
| 66 | + - db:/var/lib/postgresql/data |
| 67 | + healthcheck: |
| 68 | + test: ["CMD-SHELL", "pg_isready -U hydroserver"] |
| 69 | + interval: 10s |
| 70 | + timeout: 5s |
| 71 | + retries: 5 |
| 72 | + |
| 73 | +volumes: |
| 74 | + db: |
| 75 | + static: |
| 76 | + media: |
| 77 | +``` |
| 78 | +
|
| 79 | +For a more in-depth guide on how to use Docker Compose, visit their [documentation page](https://docs.docker.com/compose/). |
| 80 | +
|
| 81 | +## Environment Variables |
| 82 | +
|
| 83 | +There are several environment variables that can be used to configure HydroServer: |
| 84 | +- **`PROXY_BASE_URL`** – The domain name for HydroServer, including the protocol (e.g., `https://yourdomain.com`). |
| 85 | +- **`DATABASE_URL`** _(Optional)_ – The PostgreSQL database URL HydroServer will connect to. |
| 86 | + *Format:* `postgresql://{user}:{password}@{host}:{port}/{database}` |
| 87 | +- **`SMTP_URL`** – Required for email notifications (account verification, password reset). |
| 88 | + *Format:* `smtps://{user}:{password}@{host}:{port}` |
| 89 | +- **`DEBUG`** _(Optional, default: `True`)_ – Set to `True` for non-production deployments. |
| 90 | +- **`ACCOUNT_SIGNUP_ENABLED`** _(Optional, default: `False`)_ – If `False`, admins must create user accounts. |
| 91 | +- **`ACCOUNT_OWNERSHIP_ENABLED`** _(Optional, default: `False`)_ – If `False`, users cannot create new workspaces. |
| 92 | +- **`SOCIALACCOUNT_SIGNUP_ONLY`** _(Optional, default: `False`)_ – If `True`, only third-party identity providers can be used for signup. |
| 93 | +- **`ENABLE_AUDITS`** _(Optional, default: `False`)_ – If `True`, HydroServer records database audit logs. |
| 94 | + |
| 95 | +## Persistent Data |
| 96 | + |
| 97 | +The example compose file defines three named volumes: |
| 98 | +- **`db`** -> Stores PostgreSQL data. |
| 99 | +- **`static`** -> Stores Django static files. |
| 100 | +- **`media`** -> Stores HydroServer media files (photos). |
| 101 | + |
| 102 | +In a production environment, static and media files should not be served directly by HydroServer. A separate service |
| 103 | +such as **NGINX** can be set up to route traffic to HydroServer and serve these files from `/static/` and `/media/` |
| 104 | +respectively. |
| 105 | + |
| 106 | +## Configure HydroServer |
| 107 | + |
| 108 | +Once HydroServer is set up and running, there are additional configuration settings you can manage through the admin dashboard. |
| 109 | + |
| 110 | +1. Log in to the HydroServer admin dashboard. |
| 111 | +2. Go to **Sites** > **example.com** and update the default domain to match your HydroServer domain. |
| 112 | +3. Go to **Web** to configure additional website settings. |
| 113 | + - **Instance Configuration**: Customize the HydroServer `About` page to add information about your organization. |
| 114 | + - **Analytics Configuration**: Optionally enable [Microsoft Clarity](https://clarity.microsoft.com/) for your instance. |
| 115 | + - **Map Configuration**: Customize the default map layers, view, geospatial, and elevation services. |
| 116 | + - **Map Layers**: Add additional map layer options for pages that use maps. |
| 117 | + - **Contact Information**: Add additional contact information for your organization to be displayed on the `About` page. |
| 118 | +4. Navigate to **Social Applications** > **Add Social Application** to register identity providers (e.g., Google, HydroShare). |
| 119 | + - Select a provider from the list of supported providers. |
| 120 | + - Choose a unique ID and name for the provider. |
| 121 | + - Enter the client ID/key and secret key you received from the provider. |
| 122 | + - Enter optional JSON settings for the provider |
| 123 | + - **allowSignUp**: (true/false) — Controls whether this provider can be used for user sign up and login. |
| 124 | + - **allowConnection**: (true/false) — Controls whether users can connect to existing HydroServer accounts. |
| 125 | + - Select the default site to allow the provider to authenticate users for. |
| 126 | +5. Populate the following models with default data you want available to all users, or load the preset defaults by clicking **Load Default Data** for each model: |
| 127 | + - Roles |
| 128 | + - Observed Properties |
| 129 | + - Processing Levels |
| 130 | + - Result Qualifiers |
| 131 | + - Sensors |
| 132 | + - Units |
| 133 | +6. To configure HydroShare archival, do the following: |
| 134 | + - Configure HydroShare as an identity provider under **Social Applications**. |
| 135 | + - Add the following settings block to the HydroShare social application record: |
| 136 | + ```json |
| 137 | + { |
| 138 | + "allowSignUp": false, |
| 139 | + "allowConnection": true |
| 140 | + } |
| 141 | + ``` |
| 142 | + - Navigate to **Orchestration Systems** > **Add Orchestration System** and create a new record with the name "HydroShare Archival Manager" and type "HydroShare". |
| 143 | + - Note: This HydroShare archival setup method is temporary and will be deprecated in a future release. |
0 commit comments