diff --git a/.github/deploy/README.md b/.github/deploy/README.md deleted file mode 100644 index 05395bf..0000000 --- a/.github/deploy/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# `matrix` - -Sonr Communication infrastructure which allows for Sonr Blockchain -Identities to have a secure and private communication channel. diff --git a/.github/deploy/devbox.json b/.github/deploy/devbox.json index 4e34c27..e0af9f7 100644 --- a/.github/deploy/devbox.json +++ b/.github/deploy/devbox.json @@ -5,8 +5,7 @@ "PATH": "$HOME/.cargo/bin:$HOME/go/bin:$HOME/.local/bin:$HOME/.bun/bin:$PATH", "GITHUB_TOKEN": "$GITHUB_TOKEN", "GOPATH": "$HOME/go", - "GOBIN": "$GOPATH/bin", - "GHQ_ROOT": "$CLONEDIR" + "GOBIN": "$GOPATH/bin" }, "shell": { "init_hook": [], diff --git a/.github/deploy/process-compose.yaml b/.github/deploy/process-compose.yaml index 64e8587..42074d1 100644 --- a/.github/deploy/process-compose.yaml +++ b/.github/deploy/process-compose.yaml @@ -1,28 +1,6 @@ version: "0.5" processes: - Tigerbeetle: - namespace: sonr-gateway - command: "tigerbeetle" - ready_log_line: "Tigerbeetle is ready" - - Postgres: - namespace: testnet - command: "postgres" - ready_log_line: "database system is ready to accept connections" - Hway: - namespace: sonr-gateway + namespace: hway-gateway command: "hway" - depends_on: - IPFS: - condition: process_log_ready - Sonr: - condition: process_started - - Cloudflare: - namespace: sonr-gateway - command: "cloudflared tunnel route" - depends_on: - Hway: - condition: process_started diff --git a/docker/hooks.Dockerfile b/docker/hooks.Dockerfile new file mode 100644 index 0000000..820af86 --- /dev/null +++ b/docker/hooks.Dockerfile @@ -0,0 +1,57 @@ +# Stage 0: Build the thing +# Need debian based image to build the native rust module +# as musl doesn't support cdylib +FROM node:20-slim AS builder + +ARG GIT_SOURCE_REPO="https://github.com/matrix-org/matrix-hookshot.git" +ARG GIT_SOURCE_BRANCH="main" + +# Needed in order to build rust FFI bindings. +RUN apt-get update && apt-get install -y build-essential cmake curl pkg-config pkg-config libssl-dev git + +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal +ENV PATH="/root/.cargo/bin:${PATH}" + +# arm64 builds consume a lot of memory if `CARGO_NET_GIT_FETCH_WITH_CLI` is not +# set to true, so we expose it as a build-arg. +ARG CARGO_NET_GIT_FETCH_WITH_CLI=false +ENV CARGO_NET_GIT_FETCH_WITH_CLI=$CARGO_NET_GIT_FETCH_WITH_CLI + +RUN git clone -b $GIT_SOURCE_BRANCH $GIT_SOURCE_REPO /src +WORKDIR /src +RUN yarn config set yarn-offline-mirror /cache/yarn +RUN yarn --ignore-scripts --pure-lockfile --network-timeout 600000 + +# Workaround: Need to install esbuild manually https://github.com/evanw/esbuild/issues/462#issuecomment-771328459 +RUN node node_modules/esbuild/install.js +RUN yarn build + + +# Stage 1: The actual container +FROM node:20-slim + +WORKDIR /bin/matrix-hookshot + +RUN apt-get update && apt-get install -y openssl ca-certificates + +COPY --from=builder /src/yarn.lock /src/package.json ./ +COPY --from=builder /cache/yarn /cache/yarn +RUN yarn config set yarn-offline-mirror /cache/yarn + +RUN yarn --network-timeout 600000 --production --pure-lockfile && yarn cache clean + +COPY --from=builder /src/lib ./ +COPY --from=builder /src/public ./public +COPY --from=builder /src/assets ./assets + +COPY apps/hooks.sonr.chat/registration.yml /data/registration.yml +COPY apps/hooks.sonr.chat/passkey.pem /data/passkey.pem +COPY config/hookshot.yml /data/config.yml + +ENV NODE_ENV="production" + +VOLUME /data +EXPOSE 9993 +EXPOSE 7775 + +CMD ["node", "/bin/matrix-hookshot/App/BridgeApp.js", "/data/config.yml", "/data/registration.yml"] diff --git a/docker/matrix.Dockerfile b/docker/matrix.Dockerfile index 859b233..d09cbbd 100644 --- a/docker/matrix.Dockerfile +++ b/docker/matrix.Dockerfile @@ -1,5 +1,3 @@ - - # For goreleaser FROM scratch ENTRYPOINT ["/hway"] diff --git a/docker/server.Dockerfile b/docker/server.Dockerfile new file mode 100644 index 0000000..440a35b --- /dev/null +++ b/docker/server.Dockerfile @@ -0,0 +1,24 @@ + +# Use the dendrite-monolith image from matrixdotorg +FROM matrixdotorg/synapse:latest + +RUN mkdir -p /data + +# Copy App Services +COPY apps/hooks.sonr.chat/registration.yml /data/svc/hookshot.yml + +# Copy the hookshot passkey +COPY apps/sonr.chat/server.crt /data/server.crt +COPY apps/sonr.chat/server.key /data/server.key +COPY apps/sonr.chat/signing.key /data/sonr.chat.signing.key + +# Copy the synapse configuration +COPY config/synapse.yaml /data/homeserver.yaml +COPY config/log.config /data/sonr.chat.log.config + +# Expose the necessary ports +EXPOSE 8008 +EXPOSE 8448 + +# Set volumes for media, jetstream, and search index +ENTRYPOINT ["./start.py"] diff --git a/docker/sync.Dockerfile b/docker/sync.Dockerfile new file mode 100644 index 0000000..0f669b7 --- /dev/null +++ b/docker/sync.Dockerfile @@ -0,0 +1,30 @@ +FROM docker.io/golang:1.20-alpine AS base + +WORKDIR /build +RUN mkdir -p /out +RUN apk --update --no-cache add build-base git +ARG GIT_SOURCE_REPO="https://github.com/matrix-org/sliding-sync.git" +ARG GIT_SOURCE_BRANCH="main" + +RUN git clone ${GIT_SOURCE_REPO} . + +ARG BINARYNAME=syncv3 +RUN go build -o /out/syncv3 "./cmd/$BINARYNAME" + +FROM alpine:3.17 + +RUN apk --update --no-cache add curl +COPY --from=base /out/* /usr/bin/ + +ENV SYNCV3_SERVER="https://sonr.chat" +ENV SYNCV3_DB="postgresql://neondb_owner:4zHmfZpEB6wQ@ep-square-wildflower-a52z3tuw.us-east-2.aws.neon.tech/neondb?sslmode=require" +ENV SYNCV3_SECRET="d1caeb5d86bee467e51a8650aa44e21ad68103d9495872015fbd36c0b9de4957" +ENV SYNCV3_BINDADDR="0.0.0.0:8008" + +EXPOSE 8008 + +WORKDIR /usr/bin +# It would be nice if the binary we exec was called $BINARYNAME here, but build args +# aren't expanded in ENTRYPOINT directives. Instead, we always call the output binary +# "syncv3". (See https://github.com/moby/moby/issues/18492) +ENTRYPOINT /usr/bin/syncv3 diff --git a/docker/web.Dockerfile b/docker/web.Dockerfile new file mode 100644 index 0000000..fffa17e --- /dev/null +++ b/docker/web.Dockerfile @@ -0,0 +1,39 @@ +# Builder +FROM node:20-bullseye as builder + +# Support custom branches of the react-sdk and js-sdk. This also helps us build +# images of element-web develop. +ARG USE_CUSTOM_SDKS=false +ARG REACT_SDK_REPO="https://github.com/matrix-org/matrix-react-sdk.git" +ARG REACT_SDK_BRANCH="master" +ARG JS_SDK_REPO="https://github.com/matrix-org/matrix-js-sdk.git" +ARG JS_SDK_BRANCH="master" +ARG GIT_SOURCE_REPO="https://github.com/element-hq/element-web.git" +ARG GIT_SOURCE_BRANCH="master" + +RUN apt-get update && apt-get install -y git dos2unix +RUN git clone ${GIT_SOURCE_REPO} src +WORKDIR /src +RUN git checkout ${GIT_SOURCE_BRANCH} + +RUN dos2unix /src/scripts/docker-link-repos.sh && bash /src/scripts/docker-link-repos.sh +RUN yarn --network-timeout=200000 install + +RUN dos2unix /src/scripts/docker-package.sh && bash /src/scripts/docker-package.sh + +# Copy the config now so that we don't create another layer in the app image +COPY config/element.json /src/webapp/config.json + +# App +FROM nginx:alpine-slim + +COPY --from=builder /src/webapp /app + +# Override default nginx config +COPY config/nginx.conf /etc/nginx/conf.d/default.conf + +RUN rm -rf /usr/share/nginx/html \ + && ln -s /app /usr/share/nginx/html + +# Run nginx +CMD ["nginx", "-g", "daemon off;"]