Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications through Simplex #22

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ services:
- ${STRFRY_CONF}:/etc/strfry.conf:ro
- ${STRFRY_DATA}/db:/app/strfry-db:rw
network_mode: service:tor

simplex:
build: ./simplex
command: >
bash -c "
simplex-chat -p 5225 -d /simplex_database/test_db &
sleep 5;
cd /app/simplex-chat/packages/simplex-chat-client/typescript/bot/;
node simplex_bot.js"
container_name: simplex${SUFFIX}
volumes:
- ${SIMPLEX_DB}:/simplex_database
- ${SIMPLEX_BOT}:/app/simplex-chat/packages/simplex-chat-client/typescript/bot/
network_mode: service:tor


# Example simple backup service (copy/paste to attached storage locations)
# backup:
Expand Down
3 changes: 3 additions & 0 deletions compose/env-sample/lndtn/compose.env
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ STRFRY_CONF='./env-sample/lndtn/strfry.conf'
STRFRY_URLS='./strfry/tn.onion_urls.txt'
STRFRY_DATA='/custom_path/testnet/strfry'

SIMPLEX_DB='./simplex/simplex_database'
SIMPLEX_BOT='./simplex/bot'

# Port and number of HTTP server workers for the robosats backend
WEB_LOCAL_PORT=8001
GUNICORN_WORKERS=2
Expand Down
85 changes: 85 additions & 0 deletions compose/simplex/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Stage 1: Build Haskell Simplex Chat Backend
ARG TAG=22.04
FROM ubuntu:${TAG} AS haskell-build

# Install dependencies for building simplex-chat
RUN apt-get update && apt-get install -y curl git build-essential libgmp3-dev zlib1g-dev llvm-12 llvm-12-dev libnuma-dev libssl-dev

# Set up environment variables for GHC and Cabal versions
ENV BOOTSTRAP_HASKELL_GHC_VERSION=9.6.3
ENV BOOTSTRAP_HASKELL_CABAL_VERSION=3.10.1.0

# Install ghcup for managing GHC and Cabal versions
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 sh

# Add GHCup and Cabal to PATH
ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:$PATH"

# Set the default GHC and Cabal versions
RUN ghcup set ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}" && \
ghcup set cabal "${BOOTSTRAP_HASKELL_CABAL_VERSION}"

# Copy the project source code into the container
RUN git clone https://github.com/simplex-chat/simplex-chat /project
WORKDIR /project

# Copy Linux-specific cabal configuration file
RUN cp ./scripts/cabal.project.local.linux ./cabal.project.local

# Update Cabal package list and build the executable
RUN cabal update
RUN cabal build exe:simplex-chat

# Strip debug symbols to reduce the binary size
RUN bin=$(find /project/dist-newstyle -name "simplex-chat" -type f -executable) && \
mv "$bin" ./ && \
strip ./simplex-chat

# Stage 2: Build Node.js Simplex Chat Client and Bot
FROM node:18 AS node-build

# Install git for cloning repositories
RUN apt-get update && apt-get install -y git

# Clone the SimpleX Chat repository
RUN git clone https://github.com/simplex-chat/simplex-chat /app/simplex-chat

# Set working directory to the TypeScript client folder
WORKDIR /app/simplex-chat/packages/simplex-chat-client/typescript

# Copy your bot script into the examples directory
COPY ./bot/simplex_bot.js /app/simplex-chat/packages/simplex-chat-client/typescript/bot/simplex_bot.js

# Copy the updated package.json and package-lock.json into the container
COPY ./package.json ./package-lock.json ./

# Install the required npm packages, including sqlite3
RUN npm install

# Build the client
RUN npm run build

# Final Stage: Combine Haskell Backend and Node.js Bot
FROM ubuntu:${TAG}

# Install runtime dependencies for the Haskell backend and Node.js
RUN apt-get update && apt-get install -y libgmp10 zlib1g curl

# Install Node.js and npm in the final stage
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs

# Set working directory for the final container
WORKDIR /app/simplex-chat/packages/simplex-chat-client/typescript

# Copy the built Haskell executable from the build stage
COPY --from=haskell-build /project/simplex-chat /usr/local/bin/simplex-chat

# Copy the built Node.js client and bot script from the node-build stage
COPY --from=node-build /app/simplex-chat /app/simplex-chat

# Install the required npm packages, including sqlite3
RUN npm install sqlite3 pg

# Expose necessary ports
EXPOSE 5225 3000
Loading