Skip to content

Commit

Permalink
chore: bootstrap justfile
Browse files Browse the repository at this point in the history
Also add a simple docker compose file with postgres.

```
Available recipes:
    generate-db-certs    # generate postgres TLS certificates
    generate-flutter-ffi # generate Rust and Dart flutter bridge files
    init-db
```

Related #232
  • Loading branch information
boxdot committed Dec 6, 2024
1 parent 56df9ef commit 9274ad0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
35 changes: 35 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-FileCopyrightText: 2024 Phoenix R&D GmbH <[email protected]>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

services:
postgres:
image: postgres:17.2
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: phnx_db
command: >
postgres
-c max_connections=1000
-c shared_buffers=2GB
-c ssl=on
-c ssl_cert_file=/etc/postgresql/certs/server.crt
-c ssl_key_file=/etc/postgresql/certs/server.key
-c ssl_ca_file=/etc/postgresql/certs/root.crt
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres", "-h", "127.0.0.1"]
start_period: 1s
interval: 1s
timeout: 5s
retries: 10
ports:
- ${COMPOSE_BIND_HOST:-127.0.0.1}:5432:5432
volumes:
- type: volume
source: postgres_data
target: /var/lib/postgresql/data
- ./backend/test_certs:/etc/postgresql/certs:ro

volumes:
postgres_data:
19 changes: 19 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2024 Phoenix R&D GmbH <[email protected]>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

export DATABASE_URL := "postgres://postgres:password@localhost:5432/phnx_db"

# run postgres via docker compose and apply migrations
init-db: generate-db-certs
docker compose up --wait
cd backend && sqlx database create
cd backend && sqlx database setup

# generate postgres TLS certificates
generate-db-certs:
cd backend && TEST_CERT_DIR_NAME=test_certs scripts/generate_test_certs.sh

# generate Rust and Dart flutter bridge files
generate-flutter-ffi:
cd prototype && make frb-generate

0 comments on commit 9274ad0

Please sign in to comment.