From 9334c45b1cb11d716a7d74146d6b6ff4ea61b2fb Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 8 Apr 2022 15:30:40 +0100 Subject: [PATCH] I have no idea what I'm doing --- build/docker/DendriteJS.Dockerfile | 10 ++++---- cmd/dendritejs-pinecone/main.go | 3 ++- go.mod | 2 +- go.sum | 2 ++ internal/sqlutil/migrate.go | 3 +++ internal/sqlutil/migrate_wasm.go | 37 ++++++++++++++++++++++++++++++ 6 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 internal/sqlutil/migrate_wasm.go diff --git a/build/docker/DendriteJS.Dockerfile b/build/docker/DendriteJS.Dockerfile index 5e1cffcad..e21b47eb2 100644 --- a/build/docker/DendriteJS.Dockerfile +++ b/build/docker/DendriteJS.Dockerfile @@ -5,25 +5,25 @@ # $ docker build -t dendritejs -f DendriteJS.Dockerfile . # $ docker run --rm -p 8888:80 dendritejs # Then visit http://localhost:8888 -FROM golang:1.14-alpine AS gobuild +FROM golang:1.18-alpine AS gobuild # Download and build dendrite WORKDIR /build ADD https://github.com/matrix-org/dendrite/archive/main.tar.gz /build/main.tar.gz RUN tar xvfz main.tar.gz WORKDIR /build/dendrite-main -RUN GOOS=js GOARCH=wasm go build -o main.wasm ./cmd/dendritejs +RUN GOOS=js GOARCH=wasm go build -o main.wasm ./cmd/dendritejs-pinecone FROM node:14-stretch AS jsbuild # apparently some deps require python -RUN apt-get update && apt-get -y install python +RUN apt-get update && apt-get -y install python libpangocairo-1.0-0 libpango1.0-dev # Download riot-web and libp2p repos WORKDIR /build -ADD https://github.com/matrix-org/go-http-js-libp2p/archive/main.tar.gz /build/libp2p.tar.gz +ADD https://github.com/matrix-org/go-http-js-libp2p/archive/master.tar.gz /build/libp2p.tar.gz RUN tar xvfz libp2p.tar.gz -ADD https://github.com/vector-im/element-web/archive/matthew/p2p.tar.gz /build/p2p.tar.gz +ADD https://github.com/neilalexander/element-web/archive/matthew/p2p.tar.gz /build/p2p.tar.gz RUN tar xvfz p2p.tar.gz # Install deps for element-web, symlink in libp2p repo and build that too diff --git a/cmd/dendritejs-pinecone/main.go b/cmd/dendritejs-pinecone/main.go index 211b3e131..07800f126 100644 --- a/cmd/dendritejs-pinecone/main.go +++ b/cmd/dendritejs-pinecone/main.go @@ -166,7 +166,8 @@ func startup() { cfg.RoomServer.Database.ConnectionString = "file:/idb/dendritejs_roomserver.db" cfg.SyncAPI.Database.ConnectionString = "file:/idb/dendritejs_syncapi.db" cfg.KeyServer.Database.ConnectionString = "file:/idb/dendritejs_e2ekey.db" - cfg.Global.JetStream.StoragePath = "file:/idb/dendritejs/" + cfg.Global.JetStream.StoragePath = "file:/idb/" + cfg.Global.JetStream.InMemory = true cfg.Global.TrustedIDServers = []string{} cfg.Global.KeyID = gomatrixserverlib.KeyID(signing.KeyID) cfg.Global.PrivateKey = sk diff --git a/go.mod b/go.mod index a5b2cffc6..a29b45172 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/libp2p/go-libp2p-record v0.1.3 github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e github.com/matrix-org/go-http-js-libp2p v0.0.0-20200518170932-783164aeeda4 - github.com/matrix-org/go-sqlite3-js v0.0.0-20210709140738-b0d1ba599a6d + github.com/matrix-org/go-sqlite3-js v0.0.0-20220408135347-0796280c79b7 github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16 github.com/matrix-org/gomatrixserverlib v0.0.0-20220405134050-301e340659d5 github.com/matrix-org/pinecone v0.0.0-20220404141326-e526fa82f79d diff --git a/go.sum b/go.sum index 6708573a0..b025211ac 100644 --- a/go.sum +++ b/go.sum @@ -1109,6 +1109,8 @@ github.com/matrix-org/go-http-js-libp2p v0.0.0-20200518170932-783164aeeda4 h1:eq github.com/matrix-org/go-http-js-libp2p v0.0.0-20200518170932-783164aeeda4/go.mod h1:3WluEZ9QXSwU30tWYqktnpC1x9mwZKx1r8uAv8Iq+a4= github.com/matrix-org/go-sqlite3-js v0.0.0-20210709140738-b0d1ba599a6d h1:mGhPVaTht5NViFN/UpdrIlRApmH2FWcVaKUH5MdBKiY= github.com/matrix-org/go-sqlite3-js v0.0.0-20210709140738-b0d1ba599a6d/go.mod h1:e+cg2q7C7yE5QnAXgzo512tgFh1RbQLC0+jozuegKgo= +github.com/matrix-org/go-sqlite3-js v0.0.0-20220408135347-0796280c79b7 h1:5PnhTnnfUzbxbKr9cu7TGhDOgFQehjOiP6V/Pj1izsk= +github.com/matrix-org/go-sqlite3-js v0.0.0-20220408135347-0796280c79b7/go.mod h1:e+cg2q7C7yE5QnAXgzo512tgFh1RbQLC0+jozuegKgo= github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26/go.mod h1:3fxX6gUjWyI/2Bt7J1OLhpCzOfO/bB3AiX0cJtEKud0= github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16 h1:ZtO5uywdd5dLDCud4r0r55eP4j9FuUNpl60Gmntcop4= github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s= diff --git a/internal/sqlutil/migrate.go b/internal/sqlutil/migrate.go index 7518df3c8..495ba646d 100644 --- a/internal/sqlutil/migrate.go +++ b/internal/sqlutil/migrate.go @@ -1,3 +1,6 @@ +//go:build !wasm +// +build !wasm + package sqlutil import ( diff --git a/internal/sqlutil/migrate_wasm.go b/internal/sqlutil/migrate_wasm.go new file mode 100644 index 000000000..80f37a6fc --- /dev/null +++ b/internal/sqlutil/migrate_wasm.go @@ -0,0 +1,37 @@ +//go:build wasm +// +build wasm + +package sqlutil + +import ( + "database/sql" + "fmt" + "runtime" + "sort" + + "github.com/matrix-org/dendrite/setup/config" + "github.com/pressly/goose" +) + +type Migrations struct { +} + +func NewMigrations() *Migrations { + return &Migrations{} +} + +func (m *Migrations) AddMigration(up func(*sql.Tx) error, down func(*sql.Tx) error) { +} + +func (m *Migrations) AddNamedMigration(filename string, up func(*sql.Tx) error, down func(*sql.Tx) error) { + +} + +func (m *Migrations) RunDeltas(db *sql.DB, props *config.DatabaseOptions) error { + return nil +} + +func (m *Migrations) collect(current, target int64) (goose.Migrations, error) { + var migrations goose.Migrations + return migrations, nil +}