Skip to content

Commit

Permalink
feat: Database migration improvements and tests (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustl22 committed Sep 17, 2024
1 parent 896e3be commit acf6303
Show file tree
Hide file tree
Showing 13 changed files with 2,510 additions and 154 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,12 @@ jobs:
- uses: bluefireteam/melos-action@v3
- run: melos run format-check
- run: melos run analyze -- ${{ inputs.fatal_warnings && '--fatal-infos' || '--no-fatal-warnings --no-fatal-infos' }}
- name: Prepare server
working-directory: wrestling_scoreboard_server
run: |
cp .env.example .env
source .env
docker pull postgres:latest
docker run --detach --name wrestling_scoreboard_database -p ${DATABASE_HOST}:${DATABASE_PORT}:5432 -e POSTGRES_USER=${DATABASE_USER} -e POSTGRES_DATABASE=${DATABASE_NAME} -e POSTGRES_PASSWORD=${DATABASE_PASSWORD} postgres
- run: melos run test
- run: docker container rm --force wrestling_scoreboard_database
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ Tags: scoreboard, wrestling, scoring, bracket, mat, team, fight, competition, to
The App consists of three components, the client, the server and the database.
You can download the client and the server for your preferred platforms from the [Releases section](https://github.com/Oberhauser-Dev/wrestling_scoreboard/releases).

For setting up the database and hosting a server, see:
- [Database](wrestling_scoreboard_server/database/README.md)
- [Server](wrestling_scoreboard_server/README.md#setup)
For setting up the database and hosting a server, see the [Server Setup](wrestling_scoreboard_server/README.md#setup).

## Development

Expand Down
4 changes: 2 additions & 2 deletions wrestling_scoreboard_server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ JWT_ISSUER='Wrestling Scoreboard (oberhauser.dev)'
JWT_SECRET=my-ultra-secure-and-ultra-long-secret
JWT_EXPIRES_IN_DAYS=90

DATABASE_HOST='localhost'
DATABASE_HOST='127.0.0.1'
DATABASE_PORT=5432
DATABASE_USER='wrestling'
DATABASE_PASSWORD=''
DATABASE_PASSWORD='my-password'
DATABASE_NAME='wrestling_scoreboard'

# One of: ALL, FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE, SHOUT, OFF
Expand Down
25 changes: 18 additions & 7 deletions wrestling_scoreboard_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@ Wrestling software server for managing team matches and competitions.

## Setup

See [database docs](./database/README.md), to set up the Postgres database.

It is recommended to start the app with user privileges, here `www`. Avoid using root.

Download the latest server version from the [releases section](https://github.com/Oberhauser-Dev/wrestling_scoreboard/releases)
and extract it into e.g. inside `$HOME/.local/share/wrestling_scoreboard_server`
and extract it into e.g. inside `$HOME/.local/share/wrestling_scoreboard_server`.

It is recommended to start the app with user privileges, here `www`. Avoid using `root`, especially if the server is open to the public.

### Environment variables:

Create file `.env` in the `wrestling_scoreboard_server` directory.
A pre-configuration can be found in `.env.example` file. Change the values to your needs.
A pre-configuration can be found in `.env.example` file (`cp .env.example .env`). Change the values to your needs.

### Database

You can run the database e.g. in a docker container:

```shell
source .env
docker pull postgres:latest
docker run --detach --name wrestling_scoreboard_database -p ${DATABASE_HOST}:${DATABASE_PORT}:5432 -e POSTGRES_USER=${DATABASE_USER} -e POSTGRES_DATABASE=${DATABASE_NAME} -e POSTGRES_PASSWORD=${DATABASE_PASSWORD} postgres
```

For a manual / more detailed setup of the Postgres database, see the [database docs](./database/README.md).

### Run server

Expand Down Expand Up @@ -51,11 +61,12 @@ systemctl --user start wrestling-scoreboard-server.service
```

Additionally, enable session for user `www` on boot:

```bash
sudo loginctl enable-linger www
```

To view server logs:
To view server logs:
`journalctl --user -u wrestling-scoreboard-server`

### Web server
Expand Down
4 changes: 2 additions & 2 deletions wrestling_scoreboard_server/database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Then add this to your system PATH variable `C:/Program Files/PostgreSQL/<version
### Debian:

```shell
sudo apt-get install postgresql
sudo apt install postgresql
sudo apt install postgresql-client-common
sudo apt-get install postgresql-client
sudo apt install postgresql-client
```

## Setup
Expand Down
Loading

0 comments on commit acf6303

Please sign in to comment.