mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
Create docker-compose for testing purposes
This commit is contained in:
parent
c262bc26db
commit
002e4ee749
30
docker-compose.yaml
Normal file
30
docker-compose.yaml
Normal file
@ -0,0 +1,30 @@
|
||||
# THIS IS TO BE USED FOR DEVELOPMENT AND TESTING PURPOSES ONLY
|
||||
version: '3.8'
|
||||
services:
|
||||
synapse_release:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile.synapse.latest
|
||||
ports:
|
||||
- "9999:9999"
|
||||
volumes:
|
||||
- ./docker/synapse-data:/data
|
||||
synapse_registration:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile.synapse.registration
|
||||
volumes:
|
||||
- ./docker/synapse-data:/data
|
||||
depends_on: [synapse_release]
|
||||
mjolnir:
|
||||
environment:
|
||||
NODE_ENV: development
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "8005/tcp"
|
||||
volumes:
|
||||
- ./config:/data/config
|
||||
- ./lib:/mjolnir/lib
|
||||
depends_on: [synapse_registration]
|
12
docker/Dockerfile.synapse.latest
Normal file
12
docker/Dockerfile.synapse.latest
Normal file
@ -0,0 +1,12 @@
|
||||
# A custom Dockerfile to rebuild synapse from the official release + plugins
|
||||
|
||||
FROM matrixdotorg/synapse:latest
|
||||
|
||||
RUN pip show matrix-synapse
|
||||
|
||||
COPY synapse_antispam /synapse_antispam
|
||||
RUN /usr/local/bin/python -m pip install /synapse_antispam
|
||||
|
||||
VOLUME ["/data"]
|
||||
|
||||
EXPOSE 8008/tcp 8009/tcp 8448/tcp
|
6
docker/Dockerfile.synapse.registration
Normal file
6
docker/Dockerfile.synapse.registration
Normal file
@ -0,0 +1,6 @@
|
||||
# Only exists to register a user, temporary solution
|
||||
|
||||
FROM matrixdotorg/synapse:latest
|
||||
VOLUME ["/data"]
|
||||
CMD ["-c", "/data/homeserver.yaml", "-u", "mjolnir", "-p", "mjolnir", "--admin", "http://synapse_release:9999"]
|
||||
ENTRYPOINT ["register_new_matrix_user"]
|
10
docker/README.md
Normal file
10
docker/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
## Testing mjolnir with docker
|
||||
|
||||
At the moment a test environment for mjolnir can be setup by running
|
||||
`./mjolnir_testing.sh` from the parent directory. This script will use
|
||||
the `docker-compose.yaml` in the parent directory.
|
||||
|
||||
This sets up synapse container with a user for mjolnir to use.
|
||||
The container for mjolnir, creates and joins the moderation room
|
||||
which has to be specified with an alias in the config under `managementRoom`.
|
||||
Eventually this setup should be moved to a testing module.
|
70
docker/synapse-data/homeserver.yaml
Normal file
70
docker/synapse-data/homeserver.yaml
Normal file
@ -0,0 +1,70 @@
|
||||
server_name: localhost:9999
|
||||
pid_file: /data/homeserver.pid
|
||||
public_baseurl: http://localhost:9999
|
||||
listeners:
|
||||
- port: 9999
|
||||
tls: false
|
||||
type: http
|
||||
x_forwarded: true
|
||||
|
||||
resources:
|
||||
- names: [client, federation]
|
||||
compress: false
|
||||
federation_ip_range_blacklist:
|
||||
- '127.0.0.0/8'
|
||||
- '10.0.0.0/8'
|
||||
- '172.16.0.0/12'
|
||||
- '192.168.0.0/16'
|
||||
- '100.64.0.0/10'
|
||||
- '169.254.0.0/16'
|
||||
- '::1/128'
|
||||
- 'fe80::/64'
|
||||
- 'fc00::/7'
|
||||
# can not figure out how to exclude the db from the /data volume
|
||||
database:
|
||||
name: sqlite3
|
||||
args:
|
||||
database: /data/homeserver.db
|
||||
media_store_path: "/data/media_store"
|
||||
enable_registration: true
|
||||
|
||||
report_stats: false
|
||||
registration_shared_secret: "REGISTRATION_SHARED_SECRET"
|
||||
macaroon_secret_key: "MACROON_SECRET_KEY"
|
||||
#form_secret: ""
|
||||
signing_key_path: "/data/localhost:9999.signing.key"
|
||||
trusted_key_servers:
|
||||
- server_name: "matrix.org"
|
||||
suppress_key_server_warning: true
|
||||
|
||||
|
||||
rc_message:
|
||||
per_second: 10000
|
||||
burst_count: 10000
|
||||
|
||||
rc_registration:
|
||||
per_second: 10000
|
||||
burst_count: 10000
|
||||
|
||||
rc_login:
|
||||
address:
|
||||
per_second: 10000
|
||||
burst_count: 10000
|
||||
account:
|
||||
per_second: 10000
|
||||
burst_count: 10000
|
||||
failed_attempts:
|
||||
per_second: 10000
|
||||
burst_count: 10000
|
||||
|
||||
rc_admin_redaction:
|
||||
per_second: 10000
|
||||
burst_count: 10000
|
||||
|
||||
rc_joins:
|
||||
local:
|
||||
per_second: 10000
|
||||
burst_count: 10000
|
||||
remote:
|
||||
per_second: 10000
|
||||
burst_count: 10000
|
23
mjolnir_testing.sh
Executable file
23
mjolnir_testing.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
# This script only exists so that the persitent state in volumes
|
||||
# is removed. Eventually this should be moved to a module
|
||||
# managing the integration tests.
|
||||
cleanup () {
|
||||
set +e
|
||||
rm -f docker/synapse-data/homeserver.db
|
||||
set -e
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
up)
|
||||
cleanup
|
||||
exec docker-compose up
|
||||
;;
|
||||
down)
|
||||
exec docker-compose down
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {up|down}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
12
src/index.ts
12
src/index.ts
@ -44,6 +44,11 @@ if (config.health.healthz.enabled) {
|
||||
Healthz.listen();
|
||||
}
|
||||
|
||||
async function createManagementRoom(client: MatrixClient, alias: string) {
|
||||
let roomId = await client.createRoom();
|
||||
await client.createRoomAlias(alias, roomId);
|
||||
}
|
||||
|
||||
(async function () {
|
||||
const storage = new SimpleFsStorageProvider(path.join(config.dataPath, "bot.json"));
|
||||
|
||||
@ -56,6 +61,13 @@ if (config.health.healthz.enabled) {
|
||||
}
|
||||
|
||||
config.RUNTIME.client = client;
|
||||
// probably better to change to a config value
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
// expects the config value to be an alias
|
||||
// don't know what to do about that for now
|
||||
// probably should validate it so someone doesn't have a huge headache
|
||||
await createManagementRoom(client, config.managementRoom);
|
||||
}
|
||||
|
||||
client.on("room.invite", async (roomId: string, inviteEvent: any) => {
|
||||
const membershipEvent = new MembershipEvent(inviteEvent);
|
||||
|
Loading…
Reference in New Issue
Block a user