aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2023-02-14 12:47:47 +0100
committerGitHub <noreply@github.com>2023-02-14 12:47:47 +0100
commit11d9b9db0e96c51c1430d451d23cf5ae9f36e4ee (patch)
treea0837bfa69051295b76140e3940a45fc61854cab /build
parentcc59879faa57cac043cf5f1585773b301994bebf (diff)
Remove polylith/API mode (#2967)
This removes most of the code used for polylith/API mode. This removes the `/api` internal endpoints entirely. Binary size change roughly 5%: ``` 51437560 Feb 13 10:15 dendrite-monolith-server # old 48759008 Feb 13 10:15 dendrite-monolith-server # new ```
Diffstat (limited to 'build')
-rw-r--r--build/dendritejs-pinecone/main.go3
-rw-r--r--build/docker/README.md15
-rw-r--r--build/docker/docker-compose.polylith.yml143
-rwxr-xr-xbuild/docker/images-build.sh1
-rwxr-xr-xbuild/docker/images-pull.sh1
-rwxr-xr-xbuild/docker/images-push.sh1
-rw-r--r--build/gobind-yggdrasil/monolith.go7
-rw-r--r--build/scripts/Complement.Dockerfile4
-rw-r--r--build/scripts/ComplementLocal.Dockerfile10
-rw-r--r--build/scripts/ComplementPostgres.Dockerfile4
-rwxr-xr-xbuild/scripts/complement-cmd.sh8
11 files changed, 17 insertions, 180 deletions
diff --git a/build/dendritejs-pinecone/main.go b/build/dendritejs-pinecone/main.go
index f44a7748..f3fcb03e 100644
--- a/build/dendritejs-pinecone/main.go
+++ b/build/dendritejs-pinecone/main.go
@@ -177,7 +177,7 @@ func startup() {
if err := cfg.Derive(); err != nil {
logrus.Fatalf("Failed to derive values from config: %s", err)
}
- base := base.NewBaseDendrite(cfg, "Monolith")
+ base := base.NewBaseDendrite(cfg)
defer base.Close() // nolint: errcheck
rsAPI := roomserver.NewInternalAPI(base)
@@ -215,7 +215,6 @@ func startup() {
monolith.AddAllPublicRoutes(base)
httpRouter := mux.NewRouter().SkipClean(true).UseEncodedPath()
- httpRouter.PathPrefix(httputil.InternalPathPrefix).Handler(base.InternalAPIMux)
httpRouter.PathPrefix(httputil.PublicClientPathPrefix).Handler(base.PublicClientAPIMux)
httpRouter.PathPrefix(httputil.PublicMediaPathPrefix).Handler(base.PublicMediaAPIMux)
diff --git a/build/docker/README.md b/build/docker/README.md
index 7eb20d88..d8abd653 100644
--- a/build/docker/README.md
+++ b/build/docker/README.md
@@ -5,7 +5,6 @@ These are Docker images for Dendrite!
They can be found on Docker Hub:
- [matrixdotorg/dendrite-monolith](https://hub.docker.com/r/matrixdotorg/dendrite-monolith) for monolith deployments
-- [matrixdotorg/dendrite-polylith](https://hub.docker.com/r/matrixdotorg/dendrite-polylith) for polylith deployments
## Dockerfiles
@@ -15,7 +14,6 @@ repository, run:
```
docker build . --target monolith -t matrixdotorg/dendrite-monolith
-docker build . --target polylith -t matrixdotorg/dendrite-monolith
docker build . --target demo-pinecone -t matrixdotorg/dendrite-demo-pinecone
docker build . --target demo-yggdrasil -t matrixdotorg/dendrite-demo-yggdrasil
```
@@ -25,7 +23,6 @@ docker build . --target demo-yggdrasil -t matrixdotorg/dendrite-demo-yggdrasil
There are two sample `docker-compose` files:
- `docker-compose.monolith.yml` which runs a monolith Dendrite deployment
-- `docker-compose.polylith.yml` which runs a polylith Dendrite deployment
## Configuration
@@ -51,7 +48,7 @@ docker run --rm --entrypoint="" \
The key files will now exist in your current working directory, and can be mounted into place.
-## Starting Dendrite as a monolith deployment
+## Starting Dendrite
Create your config based on the [`dendrite-sample.monolith.yaml`](https://github.com/matrix-org/dendrite/blob/main/dendrite-sample.monolith.yaml) sample configuration file.
@@ -61,16 +58,6 @@ Then start the deployment:
docker-compose -f docker-compose.monolith.yml up
```
-## Starting Dendrite as a polylith deployment
-
-Create your config based on the [`dendrite-sample.polylith.yaml`](https://github.com/matrix-org/dendrite/blob/main/dendrite-sample.polylith.yaml) sample configuration file.
-
-Then start the deployment:
-
-```
-docker-compose -f docker-compose.polylith.yml up
-```
-
## Building the images
The `build/docker/images-build.sh` script will build the base image, followed by
diff --git a/build/docker/docker-compose.polylith.yml b/build/docker/docker-compose.polylith.yml
deleted file mode 100644
index de0ab0aa..00000000
--- a/build/docker/docker-compose.polylith.yml
+++ /dev/null
@@ -1,143 +0,0 @@
-version: "3.4"
-services:
- postgres:
- hostname: postgres
- image: postgres:14
- restart: always
- volumes:
- - ./postgres/create_db.sh:/docker-entrypoint-initdb.d/20-create_db.sh
- # To persist your PostgreSQL databases outside of the Docker image,
- # to prevent data loss, modify the following ./path_to path:
- - ./path_to/postgresql:/var/lib/postgresql/data
- environment:
- POSTGRES_PASSWORD: itsasecret
- POSTGRES_USER: dendrite
- healthcheck:
- test: ["CMD-SHELL", "pg_isready -U dendrite"]
- interval: 5s
- timeout: 5s
- retries: 5
- networks:
- - internal
-
- jetstream:
- hostname: jetstream
- image: nats:latest
- command: |
- --jetstream
- --store_dir /var/lib/nats
- --cluster_name Dendrite
- volumes:
- # To persist your NATS JetStream streams outside of the Docker image,
- # prevent data loss, modify the following ./path_to path:
- - ./path_to/nats:/var/lib/nats
- networks:
- - internal
-
- client_api:
- hostname: client_api
- image: matrixdotorg/dendrite-polylith:latest
- command: clientapi
- volumes:
- - ./config:/etc/dendrite
- depends_on:
- - jetstream
- - postgres
- networks:
- - internal
- restart: unless-stopped
-
- media_api:
- hostname: media_api
- image: matrixdotorg/dendrite-polylith:latest
- command: mediaapi
- volumes:
- - ./config:/etc/dendrite
- - ./media:/var/dendrite/media
- networks:
- - internal
- restart: unless-stopped
-
- sync_api:
- hostname: sync_api
- image: matrixdotorg/dendrite-polylith:latest
- command: syncapi
- volumes:
- - ./config:/etc/dendrite
- depends_on:
- - jetstream
- - postgres
- networks:
- - internal
- restart: unless-stopped
-
- room_server:
- hostname: room_server
- image: matrixdotorg/dendrite-polylith:latest
- command: roomserver
- volumes:
- - ./config:/etc/dendrite
- depends_on:
- - jetstream
- - postgres
- networks:
- - internal
- restart: unless-stopped
-
- federation_api:
- hostname: federation_api
- image: matrixdotorg/dendrite-polylith:latest
- command: federationapi
- volumes:
- - ./config:/etc/dendrite
- depends_on:
- - jetstream
- - postgres
- networks:
- - internal
- restart: unless-stopped
-
- key_server:
- hostname: key_server
- image: matrixdotorg/dendrite-polylith:latest
- command: keyserver
- volumes:
- - ./config:/etc/dendrite
- depends_on:
- - jetstream
- - postgres
- networks:
- - internal
- restart: unless-stopped
-
- user_api:
- hostname: user_api
- image: matrixdotorg/dendrite-polylith:latest
- command: userapi
- volumes:
- - ./config:/etc/dendrite
- depends_on:
- - jetstream
- - postgres
- networks:
- - internal
- restart: unless-stopped
-
- appservice_api:
- hostname: appservice_api
- image: matrixdotorg/dendrite-polylith:latest
- command: appservice
- volumes:
- - ./config:/etc/dendrite
- networks:
- - internal
- depends_on:
- - jetstream
- - postgres
- - room_server
- - user_api
- restart: unless-stopped
-
-networks:
- internal:
- attachable: true
diff --git a/build/docker/images-build.sh b/build/docker/images-build.sh
index d97a701e..bf227968 100755
--- a/build/docker/images-build.sh
+++ b/build/docker/images-build.sh
@@ -7,6 +7,5 @@ TAG=${1:-latest}
echo "Building tag '${TAG}'"
docker build . --target monolith -t matrixdotorg/dendrite-monolith:${TAG}
-docker build . --target polylith -t matrixdotorg/dendrite-monolith:${TAG}
docker build . --target demo-pinecone -t matrixdotorg/dendrite-demo-pinecone:${TAG}
docker build . --target demo-yggdrasil -t matrixdotorg/dendrite-demo-yggdrasil:${TAG} \ No newline at end of file
diff --git a/build/docker/images-pull.sh b/build/docker/images-pull.sh
index f3f98ce7..7772ca74 100755
--- a/build/docker/images-pull.sh
+++ b/build/docker/images-pull.sh
@@ -5,4 +5,3 @@ TAG=${1:-latest}
echo "Pulling tag '${TAG}'"
docker pull matrixdotorg/dendrite-monolith:${TAG}
-docker pull matrixdotorg/dendrite-polylith:${TAG} \ No newline at end of file
diff --git a/build/docker/images-push.sh b/build/docker/images-push.sh
index 248fdee2..d166d355 100755
--- a/build/docker/images-push.sh
+++ b/build/docker/images-push.sh
@@ -5,4 +5,3 @@ TAG=${1:-latest}
echo "Pushing tag '${TAG}'"
docker push matrixdotorg/dendrite-monolith:${TAG}
-docker push matrixdotorg/dendrite-polylith:${TAG} \ No newline at end of file
diff --git a/build/gobind-yggdrasil/monolith.go b/build/gobind-yggdrasil/monolith.go
index 8c2d0a00..fad850a9 100644
--- a/build/gobind-yggdrasil/monolith.go
+++ b/build/gobind-yggdrasil/monolith.go
@@ -127,8 +127,8 @@ func (m *DendriteMonolith) Start() {
cfg := &config.Dendrite{}
cfg.Defaults(config.DefaultOpts{
- Generate: true,
- Monolithic: true,
+ Generate: true,
+ SingleDatabase: true,
})
cfg.Global.ServerName = gomatrixserverlib.ServerName(hex.EncodeToString(pk))
cfg.Global.PrivateKey = sk
@@ -149,7 +149,7 @@ func (m *DendriteMonolith) Start() {
panic(err)
}
- base := base.NewBaseDendrite(cfg, "Monolith")
+ base := base.NewBaseDendrite(cfg)
base.ConfigureAdminEndpoints()
m.processContext = base.ProcessContext
defer base.Close() // nolint: errcheck
@@ -194,7 +194,6 @@ func (m *DendriteMonolith) Start() {
monolith.AddAllPublicRoutes(base)
httpRouter := mux.NewRouter()
- httpRouter.PathPrefix(httputil.InternalPathPrefix).Handler(base.InternalAPIMux)
httpRouter.PathPrefix(httputil.PublicClientPathPrefix).Handler(base.PublicClientAPIMux)
httpRouter.PathPrefix(httputil.PublicMediaPathPrefix).Handler(base.PublicMediaAPIMux)
httpRouter.PathPrefix(httputil.DendriteAdminPathPrefix).Handler(base.DendriteAdminMux)
diff --git a/build/scripts/Complement.Dockerfile b/build/scripts/Complement.Dockerfile
index 3a00fbdf..70bbe8f9 100644
--- a/build/scripts/Complement.Dockerfile
+++ b/build/scripts/Complement.Dockerfile
@@ -16,8 +16,8 @@ RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=${CGO} go build -o /dendrite ./cmd/generate-config && \
CGO_ENABLED=${CGO} go build -o /dendrite ./cmd/generate-keys && \
- CGO_ENABLED=${CGO} go build -o /dendrite ./cmd/dendrite-monolith-server && \
- CGO_ENABLED=${CGO} go test -c -cover -covermode=atomic -o /dendrite/dendrite-monolith-server-cover -coverpkg "github.com/matrix-org/..." ./cmd/dendrite-monolith-server && \
+ CGO_ENABLED=${CGO} go build -o /dendrite/dendrite ./cmd/dendrite && \
+ CGO_ENABLED=${CGO} go test -c -cover -covermode=atomic -o /dendrite/dendrite-cover -coverpkg "github.com/matrix-org/..." ./cmd/dendrite && \
cp build/scripts/complement-cmd.sh /complement-cmd.sh
WORKDIR /dendrite
diff --git a/build/scripts/ComplementLocal.Dockerfile b/build/scripts/ComplementLocal.Dockerfile
index e3fbe1aa..0b80cfc4 100644
--- a/build/scripts/ComplementLocal.Dockerfile
+++ b/build/scripts/ComplementLocal.Dockerfile
@@ -19,13 +19,13 @@ WORKDIR /runtime
# This script compiles Dendrite for us.
RUN echo '\
#!/bin/bash -eux \n\
- if test -f "/runtime/dendrite-monolith-server" && test -f "/runtime/dendrite-monolith-server-cover"; then \n\
+ if test -f "/runtime/dendrite" && test -f "/runtime/dendrite-cover"; then \n\
echo "Skipping compilation; binaries exist" \n\
exit 0 \n\
fi \n\
cd /dendrite \n\
- go build -v -o /runtime /dendrite/cmd/dendrite-monolith-server \n\
- go test -c -cover -covermode=atomic -o /runtime/dendrite-monolith-server-cover -coverpkg "github.com/matrix-org/..." /dendrite/cmd/dendrite-monolith-server \n\
+ go build -v -o /runtime /dendrite/cmd/dendrite \n\
+ go test -c -cover -covermode=atomic -o /runtime/dendrite-cover -coverpkg "github.com/matrix-org/..." /dendrite/cmd/dendrite \n\
' > compile.sh && chmod +x compile.sh
# This script runs Dendrite for us. Must be run in the /runtime directory.
@@ -35,8 +35,8 @@ RUN echo '\
./generate-keys -keysize 1024 --server $SERVER_NAME --tls-cert server.crt --tls-key server.key --tls-authority-cert /complement/ca/ca.crt --tls-authority-key /complement/ca/ca.key \n\
./generate-config -server $SERVER_NAME --ci > dendrite.yaml \n\
cp /complement/ca/ca.crt /usr/local/share/ca-certificates/ && update-ca-certificates \n\
- [ ${COVER} -eq 1 ] && exec ./dendrite-monolith-server-cover --test.coverprofile=integrationcover.log --really-enable-open-registration --tls-cert server.crt --tls-key server.key --config dendrite.yaml \n\
- exec ./dendrite-monolith-server --really-enable-open-registration --tls-cert server.crt --tls-key server.key --config dendrite.yaml \n\
+ [ ${COVER} -eq 1 ] && exec ./dendrite-cover --test.coverprofile=integrationcover.log --really-enable-open-registration --tls-cert server.crt --tls-key server.key --config dendrite.yaml \n\
+ exec ./dendrite --really-enable-open-registration --tls-cert server.crt --tls-key server.key --config dendrite.yaml \n\
' > run.sh && chmod +x run.sh
diff --git a/build/scripts/ComplementPostgres.Dockerfile b/build/scripts/ComplementPostgres.Dockerfile
index 444cb947..d4b6d3f7 100644
--- a/build/scripts/ComplementPostgres.Dockerfile
+++ b/build/scripts/ComplementPostgres.Dockerfile
@@ -34,8 +34,8 @@ RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=${CGO} go build -o /dendrite ./cmd/generate-config && \
CGO_ENABLED=${CGO} go build -o /dendrite ./cmd/generate-keys && \
- CGO_ENABLED=${CGO} go build -o /dendrite ./cmd/dendrite-monolith-server && \
- CGO_ENABLED=${CGO} go test -c -cover -covermode=atomic -o /dendrite/dendrite-monolith-server-cover -coverpkg "github.com/matrix-org/..." ./cmd/dendrite-monolith-server && \
+ CGO_ENABLED=${CGO} go build -o /dendrite/dendrite ./cmd/dendrite && \
+ CGO_ENABLED=${CGO} go test -c -cover -covermode=atomic -o /dendrite/dendrite-cover -coverpkg "github.com/matrix-org/..." ./cmd/dendrite && \
cp build/scripts/complement-cmd.sh /complement-cmd.sh
WORKDIR /dendrite
diff --git a/build/scripts/complement-cmd.sh b/build/scripts/complement-cmd.sh
index def091e2..52b063d0 100755
--- a/build/scripts/complement-cmd.sh
+++ b/build/scripts/complement-cmd.sh
@@ -4,19 +4,17 @@
if [[ "${COVER}" -eq 1 ]]; then
echo "Running with coverage"
- exec /dendrite/dendrite-monolith-server-cover \
+ exec /dendrite/dendrite-cover \
--really-enable-open-registration \
--tls-cert server.crt \
--tls-key server.key \
--config dendrite.yaml \
- -api=${API:-0} \
--test.coverprofile=complementcover.log
else
echo "Not running with coverage"
- exec /dendrite/dendrite-monolith-server \
+ exec /dendrite/dendrite \
--really-enable-open-registration \
--tls-cert server.crt \
--tls-key server.key \
- --config dendrite.yaml \
- -api=${API:-0}
+ --config dendrite.yaml
fi