# Photo Gallery

## Introduction

The gallery is an application composed of 2 containers:

* `camera-control:` Written in C++ and uses mavsdk to communicate with Auterion Payload Manager running in AuterionOS
* `gallery-service`: Written in Python and uses [Flask](https://flask.palletsprojects.com) to exposes a simple API and a WebUI with a gallery of all the pictures taken from Auterion Payload Manager

## Services in Photo Gallery App

### camera-control

This service is in charge of sending request to Auterion Payload Manager over mavlink, first we set the camera in Photo Mode and then we continuously send the `take_photo` request every 10 seconds.

This service is based on `auterion/ubuntu-mavsdk:0.35.1`. This base image is itself based on Ubuntu Focal ARM64V8 (20.04) and contains essential build dependencies to build C++ programs. It also contains mavsdk v0.35.1.\
Our container is built using the [multi-stage](https://docs.docker.com/develop/develop-images/multistage-build/) feature from Docker. In the first stage (`build-stage`) we copy our source code and build our application. In the second stage (`release-stage`), we copy the mavsdk binaries from `auterion/ubuntu-mavsdk:0.35.1` and our application binary from the first stage, we also need to install all the dependencies needed to run our application. Finally, using the command `ENTRYPOINT`, we define the startup command that Docker will use to start our container.

### gallery-service

This service is in charge of exposing a Web UI (<http://10.41.1.1:5000>) with a photo gallery. It also exposes an API using Flask framework.

This service is based on `arm64v8/python:buster`. We install Flask on top it and we copy our source code in it. Finally, using the command `ENTRYPOINT`, we define the startup command that Docker will use to start our container.

## Commands <a href="#commands" id="commands"></a>

You can build the application by running the following command:

```
make build
```

It will create an app artifact in `output/gallery.auterionos`.

After a successful build, you can connect your Skynode with USB-C and run the following command to install the application on your device:

```
make install
```

You can monitor the application execution by ssh into the device (ssh root\@10.41.1.1) and run the following command:

```
docker logs camera-control
docker logs gallery-service
```

You can stop and remove the application with the following commands:

```
cd /data/app/gallery/src 
docker-compose stop
docker-compose rm -f 
docker rmi gallery-service camera-control
```
