Skip to content

Commit

Permalink
Merge pull request #127 from hmakelin/sift-keypoints
Browse files Browse the repository at this point in the history
Service architecture and networking redesign
  • Loading branch information
hmakelin authored Aug 1, 2024
2 parents d6b2674 + 01dde48 commit bd5482e
Show file tree
Hide file tree
Showing 170 changed files with 6,659 additions and 4,243 deletions.
62 changes: 40 additions & 22 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,42 +1,60 @@
# The gisnav service uses the repo root as build context so we
# use a .dockerignore file here to prevent some files from being
# included in the image
# IDEs and editors
.idea/ # IntelliJ-based IDEs (e.g. PyCharm)
.vscode/ # Visual Studio Code

# Python virtual environment
venv/

# PyCharm generated files
.idea/

# Python bytecode
# Python bytecode and cache directories
*.pyc

# colcon created folders
build/
install/
log/

# VitePress
docs/vitepress/docs/.vitepress/dist
docs/vitepress/docs/.vitepress/build
docs/vitepress/docs/.vitepress/cache
docs/vitepress/docs/reference/

# Sphinx
docs/sphinx/build
**/__pycache__/

# General build directories (e.g., colcon, make, sphinx, VitePress)
**/build/
**/_build/
**/.build/
**/dist/
**/_dist/
**/.dist/
**/install/
**/_install/
**/.install/
**/log/
**/_log/
**/.log/
**/cache/
**/_cache/
**/.cache/

# GISNav docs build specific build folder
docs/vitepress/docs/reference

# coverage.py files
.coverage*

# SITL test log output (but leave one sample flight log)
gisnav/test/sitl/output/
*.ulg
*.ulog

# Jupyter Notebook checkpoints
# Jupyter Notebook checkpoints, notebooks
gisnav/test/sitl/ulog_analysis/.ipynb_checkpoints/
gisnav/test/sitl/ulog_analysis/output

.benchmarks/

*.egg-info

# Debian package builds
debian
.pybuild
*.deb

# mypy
.mypy_cache

# node
node_modules

# pytest
*.pytest_cache/*
49 changes: 49 additions & 0 deletions .github/workflows/build_and_upload_gisnav_compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build and upload gisnav service

on:
#push:
# # Run when new version tag is pushed
# tags:
# - v*

# Allows running manually from the Actions tab
workflow_dispatch:


jobs:
build-gisnav-service:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Build .deb inside container
run: |
docker pull ghcr.io/${{ github.repository }}:latest
docker run --name gisnav-build ghcr.io/${{ github.repository }}:latest cd /systemd/gisnav && make dist
docker cp $(docker ps -q -l):opt/colcon_ws/src/gisnav/systemd/gisnav/dist/ /tmp/build-output
- name: Find .deb file and set env
run: |
DEB_FILE=$(ls /tmp/build-output/*.deb)
echo "DEB_FILE=$DEB_FILE" >> $GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: gisnav-deb
path: ${{ env.DEB_FILE }}

upload-gisnav-service:
needs: build-gisnav-service
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: gisnav-deb

# Use GitHub releases as apt repository
- name: Upload .deb package as release artifact
run: |
echo TODO
2 changes: 1 addition & 1 deletion .github/workflows/push_gisnav_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ jobs:
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
cd colcon_ws/src/gisnav
docker buildx build --build-arg ROS_VERSION=humble --push --platform linux/amd64,linux/arm64 -f docker/mavros/Dockerfile --target gisnav -t ghcr.io/hmakelin/gisnav:${TAG:-latest} .
docker buildx build --build-arg ROS_DISTRO=humble --push --platform linux/amd64,linux/arm64 -f docker/mavros/Dockerfile --target gisnav -t ghcr.io/hmakelin/gisnav:${TAG:-latest} .
50 changes: 31 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
# IDEs and editors
.idea/
.vscode/

# Python virtual environment
venv/

# PyCharm generated files
.idea/

# Python bytecode
# Python bytecode and cache directories
*.pyc

# colcon created folders
build/
install/
log/

# VitePress
docs/vitepress/docs/.vitepress/dist
docs/vitepress/docs/.vitepress/build
docs/vitepress/docs/.vitepress/cache
docs/vitepress/docs/reference/

# Sphinx
docs/sphinx/build
**/__pycache__/

# General build directories (e.g., colcon, make, sphinx, VitePress)
**/build/
**/_build/
**/.build/
**/dist/
**/_dist/
**/.dist/
**/install/
**/_install/
**/.install/
**/log/
**/_log/
**/.log/
**/cache/
**/_cache/
**/.cache/

# GISNav docs build specific build folder
docs/vitepress/docs/reference

# coverage.py files
.coverage*

# SITL test log output (but leave one sample flight log)
gisnav/test/sitl/output/
*.ulg
*.ulog

# Jupyter Notebook checkpoints, notebooks
gisnav/test/sitl/ulog_analysis/.ipynb_checkpoints/
Expand All @@ -36,7 +46,6 @@ gisnav/test/sitl/ulog_analysis/output
*.egg-info

# Debian package builds
debian
.pybuild
*.deb

Expand All @@ -45,3 +54,6 @@ debian

# node
node_modules

# pytest
*.pytest_cache/*
78 changes: 68 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,80 @@
SHELL := /bin/bash

include gisnav/Makefile
include docker/Makefile

# The docs/Makefile has a catch-all target so it is not included here
#include docs/Makefile

.PHONY: docs
docs:
@cd docs/sphinx && sphinx-build -M markdown ./source ./build
@mkdir -p docs/vitepress/docs/reference && cp -r docs/sphinx/build/markdown/* docs/vitepress/docs/reference
@cd docs/vitepress && npm run docs:build
@cd docs/vitepress/docs/.vitepress/dist && touch .nojekyll # for GitHub Pages

.PHONY: docs-preview
docs-preview:
.PHONY: docs\ preview
docs\ preview:
@cd docs/vitepress && npm run docs:preview

.PHONY: docs-dev
docs-preview:
.PHONY: docs\ dev
docs\ dev:
@cd docs/vitepress && npm run docs:dev

.PHONY:
build:
@echo "Building the project..."
@$(MAKE) -C debian/gisnav $@

.PHONY:
dist: build
@echo "Creating distribution package..."
@$(MAKE) -C debian/gisnav $@

.PHONY: clean
clean: clean\ docs
@echo "Cleaning up..."
@$(MAKE) -C debian/gisnav $@
# TODO - build and dist

.PHONY: clean\ docs
clean\ docs:
@echo "Cleaning up documentation build files..."
@rm -rf docs/sphinx/build
@rm -rf docs/vitepress/docs/reference
@rm -rf docs/vitepress/docs/.vitepress/dist

.PHONY: install
install: dist
@echo "Installing the project and dependencies..."
@$(MAKE) -C debian/gisnav $@

.PHONY: test
test:
@echo "Running tests..."
# TODO - run unit and launch tests (do not run simulation tests)

.PHONY: lint
lint:
@echo "Running linter..."
@pre-commit run --all-files

# alias for lint - we do not have a "dry-run" option for lint, both
# lint and format may modify the files
.PHONY: format
format: lint

.PHONY: check
check: lint test
@echo "Running code quality checks..."

.PHONY: help
help:
@echo "Available targets:"
@echo " docs - Build the documentation"
@echo " docs preview - Preview the documentation"
@echo " docs dev - Run the documentation development server"
@echo " build - Build the project"
@echo " dist - Create a distribution package"
@echo " clean - Clean up all generated files"
@echo " clean docs - Clean up documentation build files only"
@echo " install - Install the project and dependencies"
@echo " test - Run the project's tests"
@echo " lint - Run the linter to check code style"
@echo " format - Automatically format the code"
@echo " check - Run linter and tests"
@echo " help - Show this help message"
13 changes: 13 additions & 0 deletions debian/gisnav/DEBIAN/control.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Source: gisnav
Section: utils
Priority: optional
Maintainer: Harri Makelin <[email protected]>
Build-Depends: debhelper (>= 9)
Standards-Version: 4.6.0
Homepage: https://gisnav.org
Package: gisnav
Version: ${VERSION}
Architecture: all
Depends: bash, docker-compose-plugin, openssh-client, coreutils, sed, x11-utils, util-linux
Description: GISNav CLI Tool
This package contains GISNav CLI ("gnc") - a Docker Compose wrapper that streamlines the deployment of GISNav system configurations. Additionally, it includes the "gisnav.service" systemd service (disabled by default) that can be used to ensure the Compose services are running on system startup.
11 changes: 11 additions & 0 deletions debian/gisnav/DEBIAN/copyright.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: gisnav
Source: https://github.com/hmakelin/gisnav

Files: *
Copyright: 2022 Harri Makelin
License: MIT
The full text of the license can be found in the LICENSE.md file
available at:
.
https://github.com/hmakelin/gisnav/blob/${VERSION}/LICENSE.md
24 changes: 24 additions & 0 deletions debian/gisnav/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
set -e

# Change to the directory where the docker-compose.yml is located
cd /etc/gisnav/docker

# The gnc CLI tool should be provided with this package
# We prepare containers here as part of the installation process so that the
# user experience is better when running `gnc start` for the first time (i.e.
# will not have to pull or build Docker images then).
# Not enabled here because this could significantly slow down install, and
# cause issues with the package manager state when users inevitably interrupt
# the lengthy build process.
#gnc build gisnav --with-dependencies
#gnc create gisnav

# Enable the gisnav.service at startup
# Not enabled automatically here because this could significantly slow down
# resource constrained edge devices.
#systemctl enable gisnav.service

echo "Installation complete. Type 'gnc help' to see available commands."

exit 0
33 changes: 33 additions & 0 deletions debian/gisnav/DEBIAN/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh
set -e

# Stop and disable the systemd service
if [ -x "$(command -v systemctl)" ]; then
if systemctl stop gisnav.service; then
echo "Successfully stopped gisnav.service."
else
echo "Could not stop gisnav.service - this is OK if the service was not running."
fi

if systemctl disable gisnav.service; then
echo "Successfully disabled gisnav.service."
else
echo "Could not disable gisnav.service - this is OK if the service was not enabled."
fi
else
echo "systemctl command not found. Skipping service stop and disable."
fi

# Execute docker compose down
if [ -x "$(command -v docker compose)" ]; then
# "down" removes containers, volumes, networks
if docker compose -p gisnav down; then
echo "Successfully executed docker compose down."
else
echo "Failed to execute docker compose down. Please stop and remove any GISNav Docker containers manually."
fi
else
echo "docker command not found. Skipping docker compose down."
fi

exit 0
Loading

0 comments on commit bd5482e

Please sign in to comment.