Skip to content

Commit 175435d

Browse files
authored
Merge pull request #152 from pvarki/mediamtx
Add support for MediaMTX
2 parents 80a46c6 + 17a6e23 commit 175435d

18 files changed

+807
-42
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.11.0
2+
current_version = 1.12.0
33
commit = False
44
tag = False
55

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@
2828
[submodule "battlelog"]
2929
path = battlelog
3030
url = git@github.com:pvarki/typescript-liveloki-app.git
31+
[submodule "mtxauthz"]
32+
path = mtxauthz
33+
url = git@github.com:pvarki/python-mediamtx-rmmtxauthz.git

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ Example .env-file with the minimal information needed::
8888
KEYCLOAK_HTTPS_KEY_STORE_PASSWORD="input-secure-password" # pragma: allowlist secret
8989
KEYCLOAK_HTTPS_TRUST_STORE_PASSWORD="input-secure-password" # pragma: allowlist secret
9090
BL_POSTGRES_PASSWORD="input-secure-password" # pragma: allowlist secret
91+
RMMTX_POSTGRES_PASSWORD="input-secure-password" # pragma: allowlist secret
92+
93+
Replace "intput-secure-password" with a good passphrase that is unique for each replacment.
9194

9295
If you wish to use one deployment for longer than the *design lifetime* of 1-2 months you can change the following
9396
env variables. But do understand that this is **not recommended** and has **security implications**. If you do this

docker-compose-dev.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ services:
3636
volumes:
3737
- "./api:/app"
3838

39+
rmmtx:
40+
image: pvarki/rmapi:devel_shell${DOCKER_TAG_EXTRA:-}
41+
build:
42+
context: ./mtxauthz
43+
dockerfile: Dockerfile
44+
target: devel_shell
45+
command: ["-c", "source /root/.profile && poetry install && uvicorn --host 0.0.0.0 --port 8005 --log-level debug --factory rmmtxauthz.web.application:get_app --reload"]
46+
healthcheck:
47+
test: 'curl http://localhost:8005/api/v1/healthcheck || exit 1'
48+
interval: 5s
49+
timeout: 5s
50+
retries: 3
51+
start_period: 15s
52+
volumes:
53+
- "./api:/app"
54+
3955
rmuidev:
4056
image: pvarki/rmui:devel_shell${DOCKER_TAG_EXTRA:-}
4157
build:

docker-compose-local.yml

Lines changed: 122 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ x-ldap_admin_env: &ldap_admin_env
2727
LDAP_ADMIN_PASSWORD: &ldapadminpass ${LDAP_ADMIN_PASSWORD:-ldapadminpwd} # pragma: allowlist secret
2828
LDAP_ADMIN_USERNAME: &ldapadminuser admin
2929

30+
x-mtxauthz_dbconfig_env: &rmmtx_dbconfig_env
31+
RMMTX_DATABASE_DATABASE: &rmmtx_dbname ${RMMTX_DATABASE_DATABASE:-rmmtx}
32+
RMMTX_DATABASE_HOST: postgres
33+
RMMTX_DATABASE_USER: &rmmtx_dbuser ${RMMTX_DATABASE_USER:-rmmtx}
34+
RMMTX_DATABASE_PASSWORD: &rmmtx_dbpass ${RMMTX_DATABASE_PASSWORD:-mtxauthzdbpwd} # pragma: allowlist secret
35+
RMMTX_API_PASSWORD: &rmmtx_apipass ${RMMTX_API_PASSWORD:-rmmtxpasswd} # pragma: allowlist secret
36+
3037
x-tak_dbconfig_env: &takdbconfig_env
3138
POSTGRES_DB: &takdbname ${TAK_DATABASE_NAME:-tak}
3239
POSTGRES_ADDRESS: postgres
@@ -49,6 +56,7 @@ x-postgres_env: &postgres_env
4956
RAESENMAEHER_PASSWORD: *rmdbpass # pragma: allowlist secret
5057
TAK_PASSWORD: *takdbpass # pragma: allowlist secret
5158
BATTLELOG_PASSWORD: *bldbpass # pragma: allowlist secret
59+
RMMTX_PASSWORD: *rmmtx_dbpass # pragma: allowlist secret
5260

5361
x-keycloak_users_env: &keycloak_users_env
5462
KEYCLOAK_CREATE_ADMIN_USER: true
@@ -114,8 +122,7 @@ x-takserver_env: &takserver_env
114122
TAKSERVER_KEYSTORE_PASS: *takserver_cert_pass
115123
CA_PASS: &tak_ca_pass ${TAK_CA_PASS:-takcacertpw} # pragma: allowlist secret
116124
KEYSTORE_PASS: *tak_ca_pass
117-
TAK_OCSP_UPSTREAM: &ocsphost "ocsp"
118-
TAK_OCSP_PORT: *oscpport
125+
TAK_OCSP_ENABLE: "true"
119126
WEBTAK_ENABLE: "true"
120127

121128

@@ -128,9 +135,11 @@ services:
128135
target: production
129136
environment:
130137
MW_DOMAIN: *serverdomain
131-
MW_PRODUCTS: "tak,kc,fake,bl"
138+
MW_PRODUCTS: "tak,kc,fake,bl,rmmtx"
132139
MW_RASENMAEHER__API_PORT: *apiport
133140
MW_RASENMAEHER__USER_PORT: *apiport
141+
MW_MTX__API_PORT: *productport
142+
MW_MTX__USER_PORT: 9996
134143
MW_FAKE__API_PORT: *productport
135144
MW_FAKE__USER_PORT: *productport
136145
MW_TAK__API_PORT: *productport
@@ -144,11 +153,12 @@ services:
144153
ports:
145154
- "80:80" # For letsencrypt
146155
volumes:
156+
- kraftwerk_data:/data/persistent
157+
- kraftwerk_shared_rasenmaeher:/pvarkishares/rasenmaeher
147158
- kraftwerk_shared_fake:/pvarkishares/fake
148159
- kraftwerk_shared_tak:/pvarkishares/tak
149-
- kraftwerk_shared_rasenmaeher:/pvarkishares/rasenmaeher
150160
- kraftwerk_shared_bl:/pvarkishares/bl
151-
- kraftwerk_data:/data/persistent
161+
- kraftwerk_shared_rmmtx:/pvarkishares/rmmtx
152162
- le_certs:/le_certs
153163
- ca_public:/ca_public
154164

@@ -491,7 +501,7 @@ services:
491501
NGINX_UI_UPSTREAM: "rmui"
492502
NGINX_UI_UPSTREAM_PORT: ${NGINX_UI_UPSTREAM_PORT:-8002}
493503
NGINX_CERT_NAME: "rasenmaeher"
494-
NGINX_OCSP_UPSTREAM: *ocsphost
504+
NGINX_OCSP_UPSTREAM: "ocsp"
495505
DNS_RESOLVER_IP: *dnsresolver
496506
NGINX_TEMPLATE_DIR: "templates_rasenmaeher"
497507
networks:
@@ -618,6 +628,103 @@ services:
618628
# End: Battlelog #
619629
####################
620630

631+
###################
632+
# Begin: MediaMTX #
633+
###################
634+
rmmtx:
635+
image: pvarki/rmmtx:local${DOCKER_TAG_EXTRA:-}
636+
build:
637+
context: ./mtxauthz
638+
dockerfile: Dockerfile
639+
target: production
640+
environment:
641+
<<: [*rmmtx_dbconfig_env]
642+
RMMTX_API_URL: https://mtx.${SERVER_DOMAIN:-localmaeher.dev.pvarki.fi}:9997
643+
RMMTX_MTX_ADDRESS: mtx.${SERVER_DOMAIN:-localmaeher.dev.pvarki.fi}
644+
LOG_CONSOLE_FORMATTER: "local"
645+
RMMTX_LOG_LEVEL: "debug"
646+
UVICORN_LOG_LEVEL: "debug"
647+
ports:
648+
- "8005:8005" # NOTE: Do *NOT* expose this in production, always pass through NGinx proxy
649+
networks:
650+
- productnet
651+
- intranet
652+
- dbnet
653+
extra_hosts:
654+
- "host.docker.internal:host-gateway"
655+
volumes:
656+
- ca_public:/ca_public
657+
- kraftwerk_shared_rmmtx:/pvarki
658+
depends_on:
659+
rmnginx:
660+
condition: service_healthy
661+
rmapi:
662+
condition: service_healthy
663+
postgres:
664+
condition: service_healthy
665+
healthcheck:
666+
test: 'rmmtxauthz healthcheck || exit 1'
667+
interval: 5s
668+
timeout: 5s
669+
retries: 3
670+
start_period: 5s
671+
restart: unless-stopped
672+
673+
mediamtx_cert_perms: # FIXME: make a separate volume or something and copy the certs for correct user under it
674+
image: bash:latest
675+
volumes:
676+
- le_certs:/le_certs
677+
command: ["/usr/local/bin/bash", "-c", "chmod a+rwx -R /le_certs"]
678+
depends_on:
679+
miniwerk:
680+
condition: service_completed_successfully
681+
682+
mediamtx:
683+
image: bluenviron/mediamtx:1.12.3
684+
networks:
685+
- productnet
686+
- intranet
687+
extra_hosts:
688+
- "host.docker.internal:host-gateway"
689+
volumes:
690+
- ca_public:/ca_public
691+
- le_certs:/le_certs
692+
- ./mediamtx.yml:/mediamtx.yml
693+
environment:
694+
MTX_RTSPTRANSPORTS: "tcp" # Can't do UDP without host mode network
695+
MTX_WEBRTCADDITIONALHOSTS: *serverdomain
696+
ports:
697+
- "1936:1936"
698+
- "8322:8322"
699+
- "8890:8890"
700+
- "9000:9000"
701+
- "9001:9001"
702+
- "9888:9888"
703+
- "9889:9889"
704+
- "9996:9996"
705+
- "9997:9997" # Control API
706+
- "9998:9998" # metrics: Do not expose in production
707+
- "9999:9999" # pprof: Do not expose in production
708+
- "8890:8890/udp"
709+
- "8189:8189/udp"
710+
depends_on:
711+
rmmtx:
712+
condition: service_healthy
713+
mediamtx_cert_perms:
714+
condition: service_completed_successfully
715+
healthcheck:
716+
test: 'true' # FIXME: Proper check
717+
interval: 5s
718+
timeout: 5s
719+
retries: 3
720+
start_period: 5s
721+
restart: unless-stopped
722+
#################
723+
# End: MediaMTX #
724+
#################
725+
726+
727+
621728
##############
622729
# Begin: TAK #
623730
##############
@@ -828,10 +935,12 @@ services:
828935
NGINX_BL_UPSTREAM_PORT: "3000"
829936
NGINX_TAK_UPSTREAM: "takconfig" # Due to the sidecar thing we must use the config container as host
830937
NGINX_TAK_UPSTREAM_PORT: "8003"
938+
NGINX_RMMTX_UPSTREAM: "rmmtx"
939+
NGINX_RMMTX_UPSTREAM_PORT: "8005"
831940
NGINX_CERT_NAME: "rasenmaeher"
832941
NGINX_TEMPLATE_DIR: "templates_consolidated"
833942
CFSSL_OCSP_BIND_PORT: *oscpport
834-
NGINX_OCSP_UPSTREAM: *ocsphost
943+
NGINX_OCSP_UPSTREAM: "ocsp"
835944
DNS_RESOLVER_IP: *dnsresolver
836945
networks:
837946
- productnet
@@ -843,11 +952,13 @@ services:
843952
nginx_templates:
844953
condition: service_completed_successfully
845954
rmfpapi:
846-
condition: service_healthy
955+
condition: service_started
847956
blapi:
848-
condition: service_healthy
957+
condition: service_started
849958
takrmapi:
850-
condition: service_healthy
959+
condition: service_started
960+
rmmtx:
961+
condition: service_started
851962
healthcheck:
852963
test: 'curl -s localhost:5666/healthcheck || exit 1'
853964
interval: 5s
@@ -892,3 +1003,4 @@ volumes:
8921003
nginx_templates:
8931004
kraftwerk_shared_bl:
8941005
blapi_data:
1006+
kraftwerk_shared_rmmtx:

0 commit comments

Comments
 (0)