Skip to content

Commit

Permalink
launch and use postgres in a container whilst using mx-tester
Browse files Browse the repository at this point in the history
  • Loading branch information
jesopo authored and Gnuxie committed Nov 15, 2022
1 parent a0da2e1 commit 8771ca9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions mx-tester.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: mjolnir

up:
before:
- docker run --rm --network $MX_TEST_NETWORK_NAME --name mjolnir-test-postgres --domainname mjolnir-test-postgres -e POSTGRES_PASSWORD=mjolnir-test -e POSTGRES_USER=mjolnir-tester -e POSTGRES_DB=mjolnir-test-db -d -p 127.0.0.1:8082:5432 postgres
# Wait until postgresql is ready
- until psql postgres://mjolnir-tester:mjolnir-test@localhost:8082/mjolnir-test-db -c ""; do echo "Waiting for psql..."; sleep 1s; done
# Make table in postgres
- psql postgres://mjolnir-tester:mjolnir-test@localhost:8082/mjolnir-test-db -c "CREATE TABLE mjolnir (local_part VARCHAR(255), owner VARCHAR(255), management_room TEXT)"
# Launch the reverse proxy, listening for connections *only* on the local host.
- docker run --rm --network host --name mjolnir-test-reverse-proxy -p 127.0.0.1:8081:80 -v $MX_TEST_CWD/test/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx
- cp mjolnir-registration.yaml $MX_TEST_SYNAPSE_DIR/data/
Expand All @@ -15,6 +20,7 @@ run:

down:
finally:
- docker stop mjolnir-test-postgres || true
- docker stop mjolnir-test-reverse-proxy || true

modules:
Expand Down
2 changes: 1 addition & 1 deletion src/appservice/AppService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class MjolnirAppService {
public readonly mjolnirManager: MjolnirManager = new MjolnirManager();

public constructor() {
this.dataStore = new PgDataStore("foo bar baz");
this.dataStore = new PgDataStore("postgres://mjolnir-tester:mjolnir-test@localhost:8082/mjolnir-test-db");
new Api("http://localhost:8081", this).start(9001);
this.bridge = new Bridge({
homeserverUrl: "http://localhost:8081",
Expand Down

0 comments on commit 8771ca9

Please sign in to comment.