Skip to content

Commit

Permalink
chore: docs and arch
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanBorai committed Nov 19, 2023
1 parent 5d13b6f commit 4c8cea2
Show file tree
Hide file tree
Showing 8 changed files with 609 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Matrix Client
MATRIX_HOST=http://localhost:8008
MATRIX_ADMIN_TOKEN=secret

# PostgreSQL
POSTGRES_USER=synapse_user
POSTGRES_PASSWORD=secretpassword
POSTGRES_DB=synapse
# https://www.postgresql.org/docs/current/app-initdb.html
POSTGRES_INITDB_ARGS='--no-locale --encoding=UTF8'

# Synapse
SYNAPSE_SERVER_NAME=matrix.localhost
SYNAPSE_REPORT_STATS=yes
SYNAPSE_ENABLE_REGISTRATION=yes
SYNAPSE_NO_TLS=true
SYNAPSE_USER_DIR_SEARCH_ALL_USERS=true
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Development
/docker/*
!/docker/.gitkeep
!/docker/postgre
.env

# System Specific
.DS_Store
29 changes: 29 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
set positional-arguments

# Lists all available commands
default:
just --list

# Creates the `.env` file if it doesn't exist
dotenv:
cp -n .env.example .env || true

# Generates the synapse configuration file and saves it
gen_synapse_conf: dotenv
docker run -it --rm \
-v ./docker/synapse:/data \
--env-file .env \
matrixdotorg/synapse:v1.96.1 generate

# Runs backend dependency services
backend: dotenv
docker compose up --build

# Stops backend dependency services
stop:
docker compose down

# Removes oll Docker related config, volumes and containers for this project
clear: stop
docker compose rm --all --force --volumes --stop
docker volume rm commune_synapse_database || true
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# commune
Commune Server
<div align="center">
<h1 align="center">commune</h1>
<p align="center">
Commune Server
</p>
</div>

## Development

### Requirements

- [Docker](https://www.docker.com/get-started/)
- [Justfile](https://github.com/casey/just)
- [Rust](https://rustup.rs)

### Getting Started

1. Generate `Synapse` server configuration

```bash
just gen_synapse_conf
```

2. Run Synapse Server (and other containerized services) using Docker Compose
via:

```bash
just backend
```

**When you are ready**

Teardown services using `just stop`. If you want to perform a complete cleanup
use `just clear`.

> **Warning** `just clear` will remove all containers and images.
### Application Layout

<div align="center">
<img src="./docs/diagrams/diagram.png" />
<small>Application Layout Overview</small>
</div>

The client, any HTTP Client, comunicates with the Commune Server which may or
may not communicate with Matrix's server _Synapse_ which runs along with its
database in a Docker container.

## License

This project is licensed under the Apache License Version 2.0
28 changes: 28 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: '3'

services:
synapse_database:
image: 'postgres:16'
ports:
- '5432:5432'
volumes:
- synapse_database:/var/lib/postgresql/data
env_file:
- .env
restart: always

synapse:
image: 'matrixdotorg/synapse:v1.96.1'
ports:
- '8008:8008'
- '8448:8448'
volumes:
- ./docker/synapse:/data
env_file:
- .env
restart: always
depends_on:
- synapse_database

volumes:
synapse_database:
Empty file added docker/.gitkeep
Empty file.
Loading

0 comments on commit 4c8cea2

Please sign in to comment.