Skip to content

Commit 8daeaf7

Browse files
committed
Tecnically working,
- Tasks server working from multi-client POV - Improvide documentation on starting the system
1 parent d29245e commit 8daeaf7

18 files changed

+4472
-1994
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@
3434
**/build-*
3535
**/dist
3636
LICENSE
37-
README.md
37+
README*.md

README.md

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,46 @@
22

33
In order do as follows
44

5-
## Build
5+
## Setup
6+
7+
### Docker
8+
9+
1. Copy `dbpass.txt.example` to `dbpass.txt` and set a password
10+
2. Copy `password-file.txt.example` to `password-file.txt` and set the same password
11+
12+
13+
### Local
14+
15+
1. Install **node 22**
16+
2. Run `npm install`
17+
18+
19+
## Local Development
20+
21+
### Build
22+
23+
Only required for local development
624

725
```bash
826
npm run build -ws
927
```
1028

11-
## Test
29+
### Test
1230

1331
```bash
1432
npm run test -ws
1533
```
1634

17-
## Prepare database
35+
### Prepare database
1836

1937
```bash
2038
# at a separate terminal run this and keep running
2139
docker compose -f compose.yaml -f compose.debug.yaml up db
22-
# In a separate terminal
40+
# In a separate terminal, (I believe postgresql does this automatically)
2341
npm run db:prepare -w backend
2442
```
2543

26-
## Launch
27-
28-
### *production mode*
29-
30-
```bash
31-
docker compose up
32-
```
33-
34-
App will be accessible on port 8080
44+
### Launch
3545

3646
### Hot-reload mode
3747

@@ -51,7 +61,15 @@ docker compose -f compose.yaml -f compose.debug.yaml down -v db
5161
npm run clean -ws --if-present
5262
```
5363

54-
Access `http://localhost:3000/tasks/debug/populate` to populate a few tasks
64+
Access `http://localhost:3000/tasks/debug/populate` to populate a few tasks (or click the populate button)
65+
66+
## Docker *deployment*
67+
68+
```bash
69+
docker compose up
70+
```
71+
72+
App will be accessible on port 8080
5573

5674
### Launch in debug mode
5775

compose.yaml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
# database or a cache. For examples, see the Awesome Compose repository:
99
# https://github.com/docker/awesome-compose
1010
services:
11-
1211
frontend:
1312
build:
1413
context: .
@@ -17,7 +16,8 @@ services:
1716
BACKEND_URL: http://backend:3000
1817
PORT: 8080
1918
depends_on:
20-
- backend
19+
backend:
20+
condition: service_healthy
2121
ports:
2222
- 8080:8080
2323
backend:
@@ -27,6 +27,11 @@ services:
2727
environment:
2828
NODE_ENV: production
2929
PORT: 3000
30+
PGPASSWORDFILE: /run/secrets/db-password
31+
PGHOST: db
32+
PGUSER: postgres
33+
PGPORT: 5432
34+
PGDATABASE: taskdb
3035
ports:
3136
- 3000:3000
3237
depends_on:
@@ -35,10 +40,16 @@ services:
3540
secrets:
3641
- db-password
3742
healthcheck:
38-
test: ["CMD", "curl --fail http://localhost:3000/health"]
39-
interval: 10s
40-
timeout: 5s
41-
retries: 5
43+
test:
44+
# node
45+
[
46+
'CMD',
47+
'wget --no-verbose --server-response --tries=1
48+
--spider http://localhost:3000/v1/health',
49+
]
50+
interval: 5s
51+
timeout: 1s
52+
retries: 3
4253
db:
4354
image: postgres:17-alpine
4455
restart: always
@@ -47,18 +58,25 @@ services:
4758
- db-password
4859
volumes:
4960
- db-data:/var/lib/postgresql/data
61+
- ./packages/backend/db:/docker-entrypoint-initdb.d:ro
5062
environment:
5163
POSTGRES_DB: taskdb
5264
POSTGRES_PASSWORD_FILE: /run/secrets/db-password
5365
expose:
5466
- 5432
67+
ports:
68+
- 5432:5432
69+
5570
healthcheck:
56-
test: [ "CMD", "pg_isready" ]
57-
interval: 10s
58-
timeout: 5s
59-
retries: 5
71+
test: ['CMD', 'pg_isready']
72+
interval: 5s
73+
timeout: 1s
74+
retries: 3
75+
6076
volumes:
6177
db-data:
6278
secrets:
6379
db-password:
64-
file: db/password.txt
80+
file: db/dbpass.txt
81+
db-passwordfile:
82+
file: db/password-file.txt

db/dbpass.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
YOUR_PGPASSWORD_HERE

db/password-file.txt.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# https://www.postgresql.org/docs/current/libpq-pgpass.html
2+
# hostname:port:database:username:password
3+
# copy this file to password.txt in this same folder
4+
*:*:*:postgres:YOUR_PGPASSWORD_HERE

0 commit comments

Comments
 (0)