# FRIC Git Service

## Run service with Docker container 🐳

{% hint style="success" %}
FRIC needs this to be ran in a docker container. We have not tested it any other way and Docker has been working excellently.
{% endhint %}

In an effort to scale the application and be able to archive data efficiently and be able to restore from it. FRIC uses a free and open-source git service known as **Gogs** which can be self-hosted and completed customized.

This container can be ran on any linux-based machine that is connected to the local offline network. Even on a Raspberry Pi (which is what we used)

> To learn about Gogs check out their official repository here <https://github.com/gogs/gogs>

### 📟To run Gogs using **Docker** follow these steps&#x20;

Ensure you have docker installed on your machine with `docker -v`

1. Pull the latest image with the command`docker pull gogs/gogs`
2. Create a local volume where the data will go, use the command `mkdir -p /var/gogs`
3. Run the docker image with&#x20;

```
docker run --name=fric-gogs-server -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs
```

* You can now start the container instance with `docker start fric-gogs-server`

You should now be able to go through the initial setup of the service by visiting `http://ip:10022/` and just replace the word **IP** with whatever the IP address of your host machine is.

> Note that the name of the container, the ports, and the volume location can all be changed if  need be. For more details visit <https://github.com/gogs/gogs/tree/main/docker>

### ARM vs 64-bit Install

It is important to note, that the instructions above show how to run Gogs in the general case where there is a full linux machine to host the service on which is usually 64 bit. We used a Raspberry Pi, which is an ARM Architecture so there was a different process to install docker and a different version of **gogs** that had to be installed.&#x20;

### 🥧 To run Gogs on Raspberry Pi devices follow these steps

1. Download the latest version of the *hypriot* operating system through this link <https://blog.hypriot.com/downloads/>
   * *hypriot* is a free and open-source, specially-built operating system designed to run Docker on ARM devices such as the Raspberry Pi.
2. Flash this image onto an SD card using a tool like Win-32 Disk Imager, Belena Etcher, or the `dd` command on Linux.
3. Once the image is loaded to the SD card, place the SD card into the Raspberry Pi and power it on.
4. Log in to the raspberry pi using the default credentials `pirate` and `hypriot` as username and password, respectively. **Note** that these might change in the future, please reference the documenation for the hypriot operating system here <https://blog.hypriot.com/faq/> to see if the default credentials have been changed.
5. You should now be able to check that docker is installed with `docker info`
6. Now we can install gogs with

```
docker run -d --name fric-gogs-server --publish 8022:22 --publish 3000:3000 --volume `pwd`/gogs-data/:/data hypriot/rpi-gogs-raspbian
```

> The main difference in the docker command is that the Gogs image needs to be a different build because of the ARM architecture, so we install the Raspbian version

Success 👍&#x20;

you should now be able to open a browser, visit the IP of the Raspberry Pi, followed by port `3000` in this case, and see the setup page for Gogs.
