Skip to content

Commit ea6a59d

Browse files
committed
Update README.md and backup dump
1 parent 7adf47e commit ea6a59d

File tree

5 files changed

+33
-39
lines changed

5 files changed

+33
-39
lines changed

README.md

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,43 @@
1-
# Welcome to Remix!
1+
# Welcome to [Krokelo](https://krokelo.sb1u.no/)!
22

3-
- [Remix Docs](https://remix.run/docs)
3+
Krokelo is a web application created to track [Crocinole](https://en.wikipedia.org/wiki/Crokinole) games at SpareBank 1 Utvikling. You can submit duel games (1 vs 1) and team games (2 vs 2), and the application will calculate [Elo ratings](https://en.wikipedia.org/wiki/Elo_rating_system) for players and teams. Leaderboard and profile pages shows the current stats.
44

5-
## Possible Todos
6-
7-
- [ ] Make it possible for players to be anonymous at stats and profile page.
8-
- [ ] Match history for players
9-
- [ ] Heat map for time of matches
5+
The application is implemented in [Remix](https://remix.run/docs) with a [Postgres](https://en.wikipedia.org/wiki/PostgreSQL) database.
106

117
## Development
128

13-
From your terminal:
9+
### Spin up a Postgres dataabse
1410

1511
```sh
16-
npm run dev
12+
docker run --name postgres16 -e POSTGRES_DB=krokelo -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=666 -p 5432:5432 -d postgres:16
1713
```
1814

19-
This starts your app in development mode, rebuilding assets on file changes.
20-
21-
## Local db setup
22-
23-
To run the app locally first you need a database to connect to.
24-
25-
### Spin up the postgres database image
15+
### Create a .env file with required environment variables
2616

27-
`docker run --name postgres16 -e POSTGRES_DB=railway -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=666 -p 5432:5432 -d postgres:16`
17+
```
18+
DATABASE_URL="postgresql://postgres:666@localhost:5432/krokelo"
19+
COOKIE_SECRET="s3cr3ts3cr3t"
20+
```
2821

29-
### Add a .env file locally to define the DATABASE_URL
22+
### Start app in development mode
3023

31-
`DATABASE_URL="postgresql://postgres:666@localhost:5432/railway"`
24+
```sh
25+
npm install # Install dependencies
26+
npm run setup:db # Setup Prisma and migrate database
27+
npm run dev # Start app in dev mode with hot reload
28+
```
3229

33-
### Use prod data in local dev
30+
### (Optional) Use prod data in local dev
3431

3532
There is a backup of the production data included in this project in the db_backups folder.
3633
You can use this to get a more realistic dev env.
3734
You can restore the backup data to your local db instance in pgadmin4 or via terminal:
3835

3936
```sh
40-
docker cp db_backups/10feb2024.sql {container_id}:/10feb2024.sql
41-
docker exec -i postgres16 pg_restore -U postgres -d railway 10feb2024.sql
37+
docker cp db_backups/03oct2024.dump {container_id}:/03oct2024.dump
38+
docker exec -i postgres16 pg_restore --clean --no-owner --no-privileges -U postgres -d krokelo 03oct2024.dump
4239
```
4340

44-
### Run prisma migration
45-
46-
`npm run setup:db`
47-
4841
## Deployment
4942

5043
First, build your app for production:
@@ -59,13 +52,13 @@ Then run the app in production mode:
5952
npm start
6053
```
6154

62-
Now you'll need to pick a host to deploy it to.
63-
64-
### DIY
65-
66-
If you're familiar with deploying node applications, the built-in Remix app server is production-ready.
55+
### Cheat sheet commands for database backup and restore
6756

68-
Make sure to deploy the output of `remix build`
69-
70-
- `build/`
71-
- `public/build/`
57+
```sh
58+
# Backup database
59+
pg_dump -Fc "postgresql://username:password@host:port/dbname" > db.dump
60+
# Restore database (same owner and roles)
61+
pg_restore --verbose -d dbname db.dump -h host -p port -U username
62+
# Restore database (new owners and roles)
63+
pg_restore --verbose --no-owner --role=username -d dbname db.dump -h host -p port -U username
64+
```

db_backups/03oct2024.dump

161 KB
Binary file not shown.

db_backups/10feb2024.sql

-86 KB
Binary file not shown.

eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import jsxa11y from 'eslint-plugin-jsx-a11y';
77
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
88

99
export default [
10+
{
11+
ignores: ['public/*'],
12+
},
1013
{
1114
files: ['app/**/*.{ts,tsx}'],
1215
languageOptions: {

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
"build": "remix build",
88
"deploy:db": "prisma migrate deploy",
99
"dev": "remix dev --manual",
10-
"lint": "eslint .",
1110
"lint:fix": "eslint . --fix",
12-
"generate:css": "tailwindcss -o ./app/styles/tailwind.css",
13-
"prettier": "prettier . --check",
11+
"lint": "eslint .",
1412
"prettier:fix": "prettier . --write",
13+
"prettier": "prettier . --check",
1514
"setup:db": "prisma migrate dev",
16-
"setup": "run-s setup:db setup:app",
1715
"start": "remix-serve build/index.js",
1816
"typecheck": "tsc --build tsconfig.json && :"
1917
},

0 commit comments

Comments
 (0)