Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Python
__pycache__/
*.py[cod]
*.pyo
*.pyd

# Virtual environments
env/
venv/
.venv/

# Editor & OS files
.DS_Store
.vscode/
.idea/

# Git
.git
.gitignore

# Build/dist
build/
dist/
*.egg-info

# Static/local settings
media/
static/
local_settings.py
*.sqlite3
*.log

# Node
node_modules/

# Docker
Dockerfile
docker-compose*.yml

# Data directory
data/

# Backups
backups/

# Vagrant
Vagrantfile
.vagrant/

# SQL files
*.sql
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ landmapper/app/testing_files
landmapper/app/static/landmapper/shapefiles/
backups/*
src/*
.env
*.sql
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,40 @@
Simple Woodland Discovery For Land Owners

## Installation
Under construction - Coming Soon!

### Docker

To run locally with Docker follow these steps (for Oregon):

Pre-requisites:
- Docker
- Docker compose
1. Clone the repo
```
git clone https://github.com/Ecotrust/landmapper.git
```
2. Check out the `dockerize` branch
```
git checkout dockerize
```
3. Clone dependent repos in a location next to the landmapper repo
```
git clone https://github.com/Ecotrust/madrona-features.git
git clone https://github.com/Ecotrust/madrona-manipulators.git
git clone https://github.com/Ecotrust/p97-nursery.git
```
4. Add the following files to the `docker/` directory. Ask an Ecotrust Software team member for these files:
- OR_TAXLOTS.sql
- OR_POPULATION_2021.sql
- FOREST_TYPES_2021.sql
- OR_SOIL_2021.sql

5. Start the docker containers using docker compose
```
docker compose up -d --build
```

6. Application should be live at `https://localhost:8000/`

---

Expand Down
16 changes: 16 additions & 0 deletions docker/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ALLOWED_HOSTS=localhost,127.0.0.1,[::1]
DEBUG=1
POSTGRES_ENGINE=django.contrib.gis.db.backends.postgis
POSTGRES_HOST=db
POSTGRES_PORT=5432
POSTGRES_DB=landmapper
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres_password_change_me
SECRET_KEY=foobar
MAPBOX_TOKEN=
GOOGLE_API_KEY=
GEOAPIFY_API_KEY=
RECAPTCHA_PUBLIC_KEY=
RECAPTCHA_PRIVATE_KEY=
ARCGIS_DEVELOPER_KEY=
GOOGLE_ANALYTICS_KEY=
88 changes: 88 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
services:
db:
container_name: db
image: postgis/postgis:18-3.6
restart: unless-stopped
platform: linux/amd64
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- landmapper_db_data:/var/lib/postgresql
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB} -h localhost -p ${POSTGRES_PORT}"]
interval: 10s
timeout: 5s
retries: 5
redis:
container_name: redis
image: redis:alpine
ports:
- "6379:6379"
landmapper:
container_name: landmapper
build:
context: ../landmapper/
dockerfile: ../landmapper/Dockerfile
restart: unless-stopped
env_file:
- path: .env
required: true
ports:
- "8000:8000"
healthcheck:
test: ["CMD-SHELL", "python manage.py check --deploy 2>/dev/null || python -c 'import urllib.request; urllib.request.urlopen(\"http://localhost:8000/\")' 2>/dev/null"]
interval: 15s
timeout: 10s
retries: 5
start_period: 30s
volumes:
- type: bind
source: ../p97-nursery
target: /usr/local/apps/landmapper/apps/p97-nursery
bind:
create_host_path: false
- type: bind
source: ../madrona-features
target: /usr/local/apps/landmapper/apps/madrona-features
bind:
create_host_path: false
- type: bind
source: ../madrona-manipulators
target: /usr/local/apps/landmapper/apps/madrona-manipulators
bind:
create_host_path: false
- static_volume:/usr/src/app/static
- media_volume:/usr/src/app/media
- ../landmapper:/usr/src/app
- ./OR_TAXLOTS.sql:/tmp/OR_TAXLOTS.sql:ro
- ./OR_POPULATION_2021.sql:/tmp/OR_POPULATION_2021.sql:ro
- ./FOREST_TYPES_2021.sql:/tmp/FOREST_TYPES_2021.sql:ro
- ./OR_SOIL_2021.sql:/tmp/OR_SOIL_2021.sql:ro
depends_on:
db:
condition: service_healthy
redis:
condition: service_started
environment:
ALLOWED_HOSTS: ${ALLOWED_HOSTS}
DEBUG: ${DEBUG}
POSTGRES_ENGINE: ${POSTGRES_ENGINE}
POSTGRES_HOST: ${POSTGRES_HOST}
POSTGRES_PORT: ${POSTGRES_PORT}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
SECRET_KEY: ${SECRET_KEY}
volumes:
landmapper_db_data:
static_volume:
media_volume:





65 changes: 65 additions & 0 deletions landmapper/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
FROM python:3.10-slim

# Prevent Python from writing .pyc files and enable unbuffered stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PIP_NO_CACHE_DIR=1

# from doc:
# sudo apt install python3-pip postgresql postgresql-contrib postgresql-server-dev-14 postgis python3-gdal libgdal-dev redis-server -y
# sudo apt install pdftk

# Install system dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
postgresql-client \
gdal-bin \
libgdal-dev \
libgeos-dev \
pdftk \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*

ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
ENV C_INCLUDE_PATH=/usr/include/gdal

ENV PYTHONPATH="/usr/local/apps/landmapper/apps/madrona-features:/usr/local/apps/landmapper/apps/p97-nursery:/usr/local/apps/landmapper/apps/madrona-manipulators:/usr/src/app"

# Set working directory
WORKDIR /usr/src/app

# Copy requirements first (cache pip install step when dependencies don't change)
COPY requirements.txt /usr/src/app/

# COPY src/madrona-features /usr/local/apps/madrona-features
# COPY src/madrona-manipulators /usr/local/apps/madrona-manipulators
# COPY src/p97-nursery /usr/local/apps/p97-nursery

# Upgrade pip and install Python dependencies
RUN pip install --upgrade pip \
&& pip install -r requirements.txt

# After installing gdal-bin and libgdal-dev, install matching version of GDAL Python bindings. This is required for Django to use GDAL.
RUN GDAL_VERSION=`gdal-config --version` && \
pip install GDAL==$GDAL_VERSION

# Copy the application code
COPY . /usr/src/app

# Copy and make entrypoint executable. The repository contains `docker/entrypoint.sh`
# which runs collectstatic, migrations and launches uWSGI.
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

# Create directory for PDF reports
RUN rm -rf /usr/src/app/app/static/landmapper/report_pdf \
&& mkdir -p /usr/src/app/app/static/landmapper/report_pdf

# Expose the port the app runs on (entrypoint starts django development server or uWSGI on 8000)
EXPOSE 8000

# Default settings module (can be overridden at runtime)
ENV DJANGO_SETTINGS_MODULE=landmapper.settings

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
4 changes: 2 additions & 2 deletions landmapper/app/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Generated by Django 4.2b1 on 2023-03-17 00:18

import app.models
import ckeditor_uploader.fields
from django.conf import settings
import django.contrib.gis.db.models.fields
from django.db import migrations, models
import django.db.models.deletion
import tinymce.models


class Migration(migrations.Migration):
Expand Down Expand Up @@ -38,7 +38,7 @@ class Migration(migrations.Migration):
('order', models.SmallIntegerField(default=10)),
('staff_only', models.BooleanField(default=False)),
('header', models.CharField(blank=True, default=None, max_length=255, null=True, verbose_name='Popup Header')),
('content', ckeditor_uploader.fields.RichTextUploadingField(blank=True, default=None, null=True, verbose_name='Popup Body')),
('content', tinymce.models.HTMLField(blank=True, default=None, null=True, verbose_name='Popup Body')),
],
),
migrations.CreateModel(
Expand Down
1 change: 0 additions & 1 deletion landmapper/app/static/landmapper/report_pdf

This file was deleted.

Loading
Loading