Skip to content

Commit

Permalink
fix: merge conflict in pdm lock file
Browse files Browse the repository at this point in the history
  • Loading branch information
nrjadkry committed Jul 24, 2024
2 parents ff8720d + 5368e0d commit 49e3e83
Show file tree
Hide file tree
Showing 24 changed files with 1,005 additions and 681 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ name: Build and Deploy Drone Tasking Manager

on:
push:
branches:
- main
branches: [main]
paths:
# Workflow is triggered only if src changes
- src/**
# Allow manual trigger
workflow_dispatch:

permissions:
Expand Down Expand Up @@ -87,8 +90,9 @@ jobs:
- name: Deploy to VM
run: |
docker compose --file docker-compose.vm.yml --env-file .env pull
bash contrib/pg-upgrade/upgrade-db.sh
docker compose --file docker-compose.vm.yml --env-file .env up \
--detach --remove-orphans --force-recreate
--detach --remove-orphans --force-recreate --pull=always
env:
DOCKER_HOST: "ssh://${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}"
26 changes: 26 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 📖 Publish Docs

on:
push:
paths:
- docs/**
- src/**
- mkdocs.yml
branches: [main]
# Allow manual trigger (workflow_dispatch)
workflow_dispatch:

jobs:
# build_openapi_json:
# uses: hotosm/gh-workflows/.github/workflows/[email protected]
# with:
# image: ghcr.io/${{ github.repository }}/backend:ci-${{ github.ref_name }}
# example_env_file_path: ".env.sample"
# output_path: docs/openapi.json

publish_docs:
uses: hotosm/gh-workflows/.github/workflows/[email protected]
# needs:
# - build_openapi_json
# with:
# openapi: true
661 changes: 0 additions & 661 deletions LICENSE

This file was deleted.

660 changes: 660 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ To get started with Drone TM:

Drone TM is an open-source project, and we welcome contributions from the community. Whether you're a developer, a drone pilot, or just passionate about mapping, you can get involved:

- **Fork the Repository**: https://github.com/hotosm/Drone-TM
- **Report Issues**: https://github.com/hotosm/Drone-TM/issues
- **Fork the Repository**: https://github.com/hotosm/drone-tm
- **Report Issues**: https://github.com/hotosm/drone-tm/issues
- **Contribute Code**: Submit pull requests for new features or bug fixes.

Join us in transforming aerial mapping through community-powered drones and create a resilient future for all.
9 changes: 9 additions & 0 deletions contrib/pg-upgrade/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM tianon/postgres-upgrade:14-to-16

RUN set -ex \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install \
-y --no-install-recommends \
"postgresql-14-postgis-3" \
"postgresql-16-postgis-3" \
&& rm -rf /var/lib/apt/lists/*
16 changes: 16 additions & 0 deletions contrib/pg-upgrade/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Postgres Version Upgrades

- Based on images from https://github.com/tianon/docker-postgres-upgrade
- Adds the PostGIS dependency and builds an image for our repo.
- The image is used for upgrading between containerised Postgres versions.

```bash
# From the repo root
bash contrib/pg-upgrade/upgrade-db.sh
```

This will start the upgrade, wait for completion, then mount
the data and start the new Postgres 16 container.

> Note it is important to shut down the postgres container first, or
> a postmaster error will be encountered.
122 changes: 122 additions & 0 deletions contrib/pg-upgrade/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# The services run in sequential order, via depends_on

volumes:
pg-14-data:
name: drone-tm-pg-14-data
pg-16-data:
external: true
name: drone-tm-pg-16-data

services:
# Check if the upgrade has already be complete --> v16
db-check-upgrade:
image: postgis/postgis:16-3.4-alpine
volumes:
- pg-16-data:/var/lib/postgresql/data
restart: "no"
entrypoint: /bin/sh -c
command:
- |
# The new database directory is empty, so continue upgrade
if [ ! -f "/var/lib/postgresql/data/PG_VERSION" ]; then
echo "Database is empty"
exit 0
fi
if [ "$(cat /var/lib/postgresql/data/PG_VERSION)" = "16" ]; then
# The database is already upgraded, skip
echo "Database already upgraded"
exit 1
else
# The database is not upgraded, continue
echo "Database not upgraded yet"
exit 0
fi
# Only required as we are migrating from filesystem to volume
db-to-volume:
image: postgis/postgis:16-3.4-alpine
volumes:
- ${PROJECT_DIR:-.}/DockerData/dtm_db_data:/var/lib/postgresql/old/data
- pg-14-data:/var/lib/postgresql/new/data
restart: "no"
entrypoint: /bin/sh -c
command:
- |
rm -rf /var/lib/postgresql/new/data
cp -r /var/lib/postgresql/old/data/* /var/lib/postgresql/new/data/
echo 'Copied postgres data to docker volume'
# Do the actual db upgrade
db-upgrade-version:
image: ghcr.io/hotosm/drone-tm/pg-upgrade:14-to-16
build: contrib/pg-upgrade
depends_on:
db-to-volume:
condition: service_completed_successfully
volumes:
- pg-14-data:/var/lib/postgresql/14/data
# Volume defined in main docker-compose.yml
- pg-16-data:/var/lib/postgresql/16/data
env_file: .env
environment:
PGUSER: ${POSTGRES_USER}
POSTGRES_INITDB_ARGS: -U ${POSTGRES_USER}
restart: "no"

# Replace the generated pg_hba.conf access file with the original
db-config-hba:
image: postgis/postgis:16-3.4-alpine
depends_on:
db-upgrade-version:
condition: service_completed_successfully
volumes:
- pg-14-data:/var/lib/postgresql/14/data
- pg-16-data:/var/lib/postgresql/16/data
restart: "no"
entrypoint: /bin/sh -c
command:
- |
cp -f \
/var/lib/postgresql/14/data/pg_hba.conf \
/var/lib/postgresql/16/data/
echo 'Copied pg_hba.conf to new postgres dir'
# Start the db so we can run maintenance tasks
db-startup:
image: postgis/postgis:16-3.4-alpine
depends_on:
db-config-hba:
condition: service_completed_successfully
volumes:
- pg-16-data:/var/lib/postgresql/data
env_file: .env
networks:
- dtm-network
restart: unless-stopped
healthcheck:
test: pg_isready -U ${POSTGRES_USER:-dtm} -d ${POSTGRES_DB:-dtm_db}
start_period: 5s
interval: 10s
timeout: 5s
retries: 3

# Run maintenance, db vacuum
db-upgrade:
image: postgis/postgis:16-3.4-alpine
depends_on:
db-startup:
condition: service_healthy
env_file: .env
networks:
- dtm-network
restart: "no"
entrypoint: /bin/sh -c
command:
- |
PGPASSWORD=${POSTGRES_PASSWORD} \
vacuumdb \
--host=db-startup \
--username=${POSTGRES_USER} \
--all \
--analyze-in-stages
50 changes: 50 additions & 0 deletions contrib/pg-upgrade/upgrade-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# Pull upgrade container
docker compose \
-f docker-compose.yml \
-f contrib/pg-upgrade/docker-compose.yml \
pull db-upgrade-version

# Get exit code from db version check
docker compose \
-f docker-compose.yml \
-f contrib/pg-upgrade/docker-compose.yml \
up db-check-upgrade --exit-code-from db-check-upgrade
exit_code=$?

# Exit script if upgrade complete
if [ "$exit_code" -eq 1 ]; then
echo "Database is already upgraded. Skipping."

docker compose \
-f docker-compose.yml \
-f contrib/pg-upgrade/docker-compose.yml \
rm --force db-check-upgrade

exit 0
fi

# Stop any existing locks on db
docker compose \
-f docker-compose.yml \
-f contrib/pg-upgrade/docker-compose.yml \
down

# Do the db upgrade
docker compose \
-f docker-compose.yml \
-f contrib/pg-upgrade/docker-compose.yml \
up -d db-upgrade

# View any logs
docker compose \
-f docker-compose.yml \
-f contrib/pg-upgrade/docker-compose.yml \
logs db-upgrade-version

# Shut down db to prior to restart
docker compose \
-f docker-compose.yml \
-f contrib/pg-upgrade/docker-compose.yml \
down
10 changes: 7 additions & 3 deletions docker-compose.vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ services:
- dtm-network

db:
image: postgis/postgis:14-3.4-alpine
restart: always
image: postgis/postgis:16-3.4-alpine
volumes:
- ${PROJECT_DIR:-.}/DockerData/dtm_db_data:/var/lib/postgresql/data/
- pg-16-data:/var/lib/postgresql/data
env_file: .env
networks:
- dtm-network
restart: unless-stopped
healthcheck:
test: pg_isready -U ${POSTGRES_USER:-dtm} -d ${POSTGRES_DB:-dtm_db}
start_period: 5s
Expand Down Expand Up @@ -80,3 +80,7 @@ services:
networks:
dtm-network:
name: dtm-network

volumes:
pg-16-data:
name: drone-tm-pg-16-data
18 changes: 11 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
version: "3"

services:
backend:
build:
context: .
dockerfile: src/backend/Dockerfile
restart: always
depends_on:
- db
- minio
Expand All @@ -16,6 +13,7 @@ services:
env_file: .env
networks:
- dtm-network
restart: unless-stopped

frontend:
build:
Expand All @@ -33,14 +31,15 @@ services:
- ${PROJECT_DIR:-.}/src/frontend:/app
- /var/run/docker.sock:/var/run/docker.sock

# If error, please upgrade the db `bash contrib/pg-upgrade/upgrade-db.sh`
db:
image: postgis/postgis:14-3.4-alpine
restart: always
image: postgis/postgis:16-3.4-alpine
volumes:
- ${PROJECT_DIR:-.}/DockerData/dtm_db_data:/var/lib/postgresql/data/
- pg-16-data:/var/lib/postgresql/data
env_file: .env
networks:
- dtm-network
restart: unless-stopped
healthcheck:
test: pg_isready -U ${POSTGRES_USER:-dtm} -d ${POSTGRES_DB:-dtm_db}
start_period: 5s
Expand All @@ -50,7 +49,6 @@ services:

minio:
image: "docker.io/minio/minio:${MINIO_TAG:-RELEASE.2023-10-25T06-33-25Z}"
restart: always
command: server /export --console-address 0.0.0.0:9090 --address 0.0.0.0:9000
volumes:
- ${PROJECT_DIR:-.}/DockerData/minio_data:/export
Expand All @@ -63,6 +61,7 @@ services:
- 9090:9090
networks:
- dtm-network
restart: unless-stopped

createbuckets:
image: "docker.io/minio/minio:${MINIO_TAG:-RELEASE.2023-10-25T06-33-25Z}"
Expand All @@ -74,6 +73,7 @@ services:
- minio
networks:
- dtm-network
restart: "no"

migrations:
build:
Expand All @@ -94,3 +94,7 @@ services:
networks:
dtm-network:
name: dtm-network

volumes:
pg-16-data:
name: drone-tm-pg-16-data
1 change: 1 addition & 0 deletions docs/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hotosm.github.io
5 changes: 5 additions & 0 deletions docs/css/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:root {
--md-primary-fg-color: #d73f3f;
--md-primary-fg-color--light: #e27575;
--md-primary-fg-color--dark: #c22929;
}
1 change: 1 addition & 0 deletions docs/images/dev_roadmap_badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/images/docs_badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/hot_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/images/timeline_badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/images/user_roadmap_badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Drone Tasking Manager

Welcome to the docs!
Loading

0 comments on commit 49e3e83

Please sign in to comment.