1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-18 20:39:36 +02:00

PostGIS migration for docker

This commit is contained in:
Sean Morley 2024-08-23 23:49:05 -04:00
parent dab6efbe32
commit e489a70980
6 changed files with 22 additions and 14 deletions

View file

@ -13,7 +13,7 @@ WORKDIR /code
# Install system dependencies # Install system dependencies
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y git postgresql-client \ && apt-get install -y git postgresql-client gdal-bin libgdal-dev \
&& apt-get clean && apt-get clean
# Install Python dependencies # Install Python dependencies

View file

@ -13,6 +13,9 @@ done
>&2 echo "PostgreSQL is up - continuing..." >&2 echo "PostgreSQL is up - continuing..."
# run sql commands
# psql -h "$PGHOST" -U "$PGUSER" -d "$PGDATABASE" -f /app/backend/init-postgis.sql
# Apply Django migrations # Apply Django migrations
python manage.py migrate python manage.py migrate

2
backend/init-postgis.sql Normal file
View file

@ -0,0 +1,2 @@
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS postgis_topology;

View file

@ -19,7 +19,7 @@ def setGeometry(region_code):
json_file = os.path.join('static/data', f'{country_code.lower()}.json') json_file = os.path.join('static/data', f'{country_code.lower()}.json')
if not os.path.exists(json_file): if not os.path.exists(json_file):
print(f'File {country_code}.json does not exist') print(f'File {country_code}.json does not exist (it probably hasn''t been added, contributors are welcome!)')
return None return None
try: try:

View file

@ -2,8 +2,8 @@ version: "3.9"
services: services:
web: web:
#build: ./frontend/ build: ./frontend/
image: ghcr.io/seanmorley15/adventurelog-frontend:latest #image: ghcr.io/seanmorley15/adventurelog-frontend:latest
environment: environment:
- PUBLIC_SERVER_URL=http://server:8000 # MOST DOCKER USERS WILL NEVER NEED TO CHANGE THIS, EVEN IF YOU CHANGE THE PORTS - PUBLIC_SERVER_URL=http://server:8000 # MOST DOCKER USERS WILL NEVER NEED TO CHANGE THIS, EVEN IF YOU CHANGE THE PORTS
- ORIGIN=http://localhost:8080 - ORIGIN=http://localhost:8080
@ -14,7 +14,7 @@ services:
- server - server
db: db:
image: postgres:latest image: postgis/postgis:15-3.3
environment: environment:
POSTGRES_DB: database POSTGRES_DB: database
POSTGRES_USER: adventure POSTGRES_USER: adventure
@ -23,8 +23,8 @@ services:
- postgres_data:/var/lib/postgresql/data/ - postgres_data:/var/lib/postgresql/data/
server: server:
#build: ./backend/ build: ./backend/
image: ghcr.io/seanmorley15/adventurelog-backend:latest #image: ghcr.io/seanmorley15/adventurelog-backend:latest
environment: environment:
- PGHOST=db - PGHOST=db
- PGDATABASE=database - PGDATABASE=database

View file

@ -167,22 +167,25 @@
<button class="py-2 px-4 btn btn-primary mt-2">Change Email</button> <button class="py-2 px-4 btn btn-primary mt-2">Change Email</button>
</form> </form>
</div> </div>
<div class="flex flex-col items-center">
<h1 class="text-center font-extrabold text-xl mt-4 mb-2">Data Export</h1> <div class="flex flex-col items-center mt-4">
<button class="btn btn-neutral mb-4" on:click={exportAdventures}> Export to JSON </button>
<p>This may take a few seconds...</p>
</div>
<div class="flex flex-col items-center">
<h1 class="text-center font-extrabold text-xl mt-4 mb-2">Visited Region Check</h1> <h1 class="text-center font-extrabold text-xl mt-4 mb-2">Visited Region Check</h1>
<p> <p>
By selecting this, the server will check all of your visited adventures and mark the regions By selecting this, the server will check all of your visited adventures and mark the regions
they are located in as "visited" in world travel. they are located in as "visited" in world travel.
</p> </p>
<button class="btn btn-neutral mb-4" on:click={checkVisitedRegions}>Update Visited Regions</button <button class="btn btn-neutral mt-2 mb-2" on:click={checkVisitedRegions}
>Update Visited Regions</button
> >
<p>This may take longer depending on the number of adventures you have.</p> <p>This may take longer depending on the number of adventures you have.</p>
</div> </div>
<div class="flex flex-col items-center mt-4">
<h1 class="text-center font-extrabold text-xl mt-4 mb-2">Data Export</h1>
<button class="btn btn-neutral mb-4" on:click={exportAdventures}> Export to JSON </button>
<p>This may take a few seconds...</p>
</div>
<small class="text-center" <small class="text-center"
><b>For Debug Use:</b> Server PK={user.pk} | Date Joined: {user.date_joined ><b>For Debug Use:</b> Server PK={user.pk} | Date Joined: {user.date_joined
? new Date(user.date_joined).toDateString() ? new Date(user.date_joined).toDateString()