Skip to content

Commit

Permalink
Update the docs (#365)
Browse files Browse the repository at this point in the history
* Update documentation files

* Update package.json scripts and documentation files
  • Loading branch information
Magnus Alexander Strømseng authored and GitHub committed Apr 23, 2024
1 parent 1db461b commit 8e59010
Show file tree
Hide file tree
Showing 10 changed files with 1,360 additions and 127 deletions.
34 changes: 11 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# Hypso Space Outreach
# Hypso Space Outreach Website
The Hypso Space Outreach Website is an interactive web page developed for the general public. It includes features such as a mission tracker, mission status, maps, and an easy to use blog.



## Project Objectives

* Develop an interactive web page for the general public.
* Include features such as mission tracker, mission status, maps, and automatic posting.
* Prioritize operational cost-effectiveness and ease of maintenance in technology and framework choices.
![alt text](docs/images/image.png)

## General Information

Expand All @@ -15,28 +10,21 @@
* Platform: Web
* Framework: React
* Period: Spring 2024
* Status: In Progress
* Status: Done

## Project Structure

* `/docs/`: Contains technical documentation.
* `/backend/`: Backend code and local setup instructions.
* `/frontend/`: Frontend code and local setup instructions.
* `/.vscode/`: IDE settings (if applicable).
* `/.github/`: GitHub repository settings (e.g., issue templates, workflows).
* [`/docs/`](/docs/): Contains technical documentation.
* [`/backend/`](/backend/): Backend code and local setup instructions.
* [`/frontend/`](/frontend/): Frontend code and local setup instructions.
* [`/.vscode/`](/.vscode/): IDE settings (if applicable).
* [`/.github/`](/.github/): GitHub repository settings (e.g., issue templates, workflows).

## Getting Started

**Instructions:**
Goto [`/docs/README.md`](/docs/README.md) to read more about the project.

1. Clone this repository.
2. Navigate to the `backend/` directory and follow the instructions within.
3. Navigate to the `frontend/` directory and follow the instructions within

## Contributing

We welcome contributions!

## More Info

If looking for more information about the project please refer to the submitted report which Small Satellite Lab should have access to as well as the documentation in the `/docs/` folder.
Contributions are welcome, for more information, refer to the documentation in the `/docs/` folder.
22 changes: 7 additions & 15 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
# Documentation Folder

See `deployment.md` for info regarding deployment.

## Overview
Welcome to the `docs/` directory! This folder is an essential part of the Hypso Outreach Portal project. It serves as a central repository for all our documentation-related materials.

## Contents
In this folder, you will find a range of documents that support and explain the project. This includes but is not limited to:

- **User Guides:** Step-by-step guides and manuals for end-users, ensuring ease of use and accessibility of our platform.
- **Technical References:** References to technologies, frameworks, libraries, and tools used in the project.
Welcome to the `docs/` directory! It serves as a central repository for all our documentation-related materials.

Other information about the project is within the submitted report detailing architecture, reasoning and more.

## Purpose
The primary purpose of this folder is to:
## Contents

1. **Organize Information:** Keep all documentation in one accessible location.
2. **Facilitate Collaboration:** Provide team members with easy access to essential project information.
3. **Support Maintenance:** Aid future developers in understanding and maintaining the system.
- [`./deployment.md`](./deployment.md) lists everything that needs to be done to deploy the server on an NTNU semi-managed server.
- [`./tech-stack.md`](./tech-stack.md) Quickly shows our tech stack and networking setup.
- [`./developing.md`](./deployment.md) Explains how to get started adding new pages and features.
- [`./design/`](./design/) Contains screenshots of our previous design iterations.
- [`./images/`](./images/) Contains images used in the docs.
119 changes: 67 additions & 52 deletions docs/deployment.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,86 @@
See the following docs for more info about strapi deployment:
[https://docs.strapi.io/dev-docs/deployment](https://docs.strapi.io/dev-docs/deployment)
# Deployment

### Setting up ntnu halfadministrated server
See the Strapi [docs](https://docs.strapi.io/dev-docs/deployment) for more info about deployment

#### Firewall
See [here](https://nextjs.org/docs/app/building-your-application/deploying) for information regarding Next.js deployment with app router.

We have created firewall rules to access website and api.
## Setting up ntnu semi-managed server

`/etc/local/firewall.d $ touch ipv4-magnastr-docker-website-git-autodeply.conf`
Look [here](https://www.ntnu.no/wiki/display/ntnuitubuntu/Semi-managed+Linux+servers) for more info about semi-managed servers

do `sudo nano ipv4-magnastr-docker-website-git-autodeply.conf` to enter the file and edit the content
### Firewall

paste the lines
We have created firewall rules to make the website accesible.

```
-I INPUT -p tcp -m tcp --dport 3000 -j ACCEPT
1. Goto
`cd /etc/local/firewall.d`

# Frontend (next.js node) Open TCP port 3000 for the world:
-I DOCKER-USER -p tcp -m conntrack --ctorigdstport 3000 -j ACCEPT
2. If they don't exist yet, do `touch ipv4-outreach.conf`

# Open port 80 for HTTP
-I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
3. do `sudo nano ipv4-outreach.conf` to enter the file and edit the content to the following:

# Open port 443 for HTTPS
-I INPUT -p tcp -m tcp --dport 443 -j ACCEPT
```
# Open port 80 for HTTP
-I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
# Backend (strapi) Open TCP port 1337 for world:
-I DOCKER-USER -p tcp -m conntrack --ctorigdstport 1337 -j ACCEPT
# Open port 443 for HTTPS
-I INPUT -p tcp -m tcp --dport 443 -j ACCEPT
```
```
4. then run `sudo /local/admin/bin/install-firewall.sh`
#### PKGSYNC
5. and `sudo iptables-save`
### PKGSYNC
Make sure docker compose is installed on the server.
Can be checked by running `docker compose version`
#### Github Runner
### Github Runner
Setup a self hosted GitHub runner for the repository.
We first need to create a user that our action runner will run as.
> Ansible (our current configuration system) will manage users and groups with UID/GID above 300. If you need to create local system users or groups, use free UID/GID between 100 and 299.
Create a user with UID 200:
`sudo useradd -u 200 outreach-github-runner`
Add it to the docker group so it can run docker commands without sudo:
`sudo usermod -a -G docker outreach-github-runner`
1. Create a user with UID 200:
`sudo useradd -u 200 outreach-github-runner`
2. Add it to the docker group so it can run docker commands without sudo:
`sudo usermod -a -G docker outreach-github-runner`
Now follow the official guide on github to add the runner to a repository, but only do theese steps
You might also have to give it permission to access the runner folder and home dircetory.
- Create the folder
- Download latest runner package
- Validate the hash
- Extract the installer
- Create the runner and start config experience. Just press enter for all options.
1. `sudo chown outreach-github-runner /actions-runner/ -R`
2. `sudo chown outreach-github-runner /home/outreach-github-runner/ -R`
No need to run it manually. We will install it as a service running as the user we created previously.
To add an action runner to the repo, goto the github repository then `Settings > Actions > Runners > New self-hosted runner`.
`./svc.sh install outreach-github-runner`
Now follow the official guide on github to add the runner to a repository, **but don't run it manually**
`sudo ./svc.sh start`
1. Create the folder
2. Download latest runner package
3. Validate the hash
4. Extract the installer
5. Create the runner and start config experience. Just press enter for all options.
`sudo chown outreach-github-runner /actions-runner/ -R`
**There is no need to run it manually.** We will install it as a service running as the user we created previously.
`sudo chown outreach-github-runner /home/outreach-github-runner/ -R`
1. `./svc.sh install outreach-github-runner` install it as a service
2. `sudo ./svc.sh start` start the service
#### Secrets and variables
### Secrets and variables
The secrets should all be filled in and generated using `openssl rand -base64 32`
The GitHub repo should define the following secrets:
- ADMIN_JWT_SECRET
- API_TOKEN_SALT
- APP_KEYS
- JWT_SECRET
- TRANSFER_TOKEN_SALT
- APP_KEYS="toBeModified1,toBeModified2"
- API_TOKEN_SALT=tobemodified
- ADMIN_JWT_SECRET=tobemodified
- TRANSFER_TOKEN_SALT=tobemodified
- JWT_SECRET=tobemodified
And the following variables:
Expand All @@ -85,22 +90,32 @@ And the following variables:
- STRAPI_URL=http://backend-app:1337
- PORT=1337
#### Logs and errors
### Apache
TODO @madshermansen
##### Action runner
## Troubleshooting
### Action runner
If the action runner is having issues, try running this command to check out its logs.
`sudo journalctl -u actions.runner.ITP2-SmallSatLab-Hypso-IT2901-SmallSatLab-Hypso.smallsat01.service -f`
`sudo journalctl -u actions.runner.NTNU-SmallSat-Lab-outreach-website.smallsat01.service -f`
If the command does not work, try reading this [Monitoring and troubleshooting self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/monitoring-and-troubleshooting-self-hosted-runners).
Keep in mind, the name might be something else than what is shown in the command. You can run `cat /actions-runner/.service` to check the name
### Logs and errors
If the command does not work, try reading this [Monitoring and troubleshooting self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/monitoring-and-troubleshooting-self-hosted-runners).
Keep in mind, the name might be something else than what is shown in the command.
1. Run `cd /actions-runner/_work/outreach-website/outreach-website`
2. Then `sudo docker compose logs` to see the logs from each container.
##### Docker
If the above doesn't work, you can run the following commands to see logs:
If there are any issues with docker. You can run the following commands to see logs:
1. `sudo docker ps -a` to see all running conatiners.
2. `sudo docker logs <hash>`, with the hash of the container (you usually only need to type in the first few letters), to see the logs printed to console.
- Log `outreach:backend` for strapi, and `outreach:frontend` for next.js.
- `sudo docker ps -a` to see all running conatiners.
- `sudo docker logs <hash>`, with the hash of the container (you usually only need to type in the first few letters), to see the logs printed to console.
## SSL Certification
Log `outreach:backend` for strapi, and `outreach:frontend` for next.js.
TODO @madshermansen
55 changes: 55 additions & 0 deletions docs/developing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Developing

## Requirements

This project requires you have installed [Node.js 20 LTS](https://nodejs.org/en/download). We recommend using [nvm](https://github.com/nvm-sh/nvm) to install multiple versions of node if necessary.

## Running the project

To install all requirements simply do the following from the project root:

`npm i && cd ./frontend && npm i && cd ../backend && npm i && cd ..` This will run npm install in all the folders necessary.

Then do `npm run dev` from the root dir to run both the client and the server at the same time.

If this doesn't work you might have to enter and build the backend (strapi) first.
`cd backend` then `npm run build`

- The frontend should be accessible at http://localhost:3000

- The backend should be accesible at http://localhost:1337/admin
- Here, you can create an admin user.

## Strapi First time boot

Goto Settings > Users & Permissions plugin > Roles > Public > Article, and enable `find` and `findOne`. You need to do this for every publically available content type. Theese include but are not limited to:

- Article
- Author
- Hero
- Most-recent-image
- Project
- Satellite

The following should **NOT** be made publicly available:

- Email
- i18n
- Upload
- User-permissions

## GraphQL Type generation

If you're using GraphQL, then you need to run `npm run compile` from `/frontend` whenever you update a schema or define a new graphQL request in the code. Make sure to import the correct `gql` as

```
import { gql } from"@/generated/gql";
```

> Any errors in your code other than the GraphQL types, can result in the codegen not working, so make sure to fix all other errors before running the codegen.
> [https://www.apollographql.com/docs/react/development-testing/static-typing/](https://www.apollographql.com/docs/react/development-testing/static-typing/)
## Strapi invite others

You can invite new admin users in `Settings > Administration panel > Users > Invite new user`
35 changes: 0 additions & 35 deletions docs/general-usage.md

This file was deleted.

Loading

0 comments on commit 8e59010

Please sign in to comment.