From 57fc190a91c3c5a07e11a2dae21341439bd0d2fc Mon Sep 17 00:00:00 2001 From: sh <37271604+shumvgolove@users.noreply.github.com> Date: Sat, 26 Nov 2022 17:29:59 +0300 Subject: [PATCH] readme: fix install steps (#570) * readme: fix install steps * correction Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> --- README.md | 99 ++++++++++++++++--- ...erver-build.Dockerfile => build.Dockerfile | 12 +-- ...download.Dockerfile => download.Dockerfile | 2 +- img/docker.svg | 1 - scripts/docker/README.md | 25 ----- scripts/docker/config/README.md | 1 - scripts/docker/entrypoint | 4 +- scripts/docker/logs/README.md | 1 - 8 files changed, 92 insertions(+), 53 deletions(-) rename scripts/docker/smp-server-build.Dockerfile => build.Dockerfile (83%) rename scripts/docker/smp-server-download.Dockerfile => download.Dockerfile (91%) delete mode 100644 img/docker.svg delete mode 100644 scripts/docker/README.md delete mode 100644 scripts/docker/config/README.md delete mode 100644 scripts/docker/logs/README.md diff --git a/README.md b/README.md index 4a6654d70..0a72d62d8 100644 --- a/README.md +++ b/README.md @@ -94,15 +94,92 @@ It's the easiest to try SMP agent via a prototype [simplex-chat](https://github. You can run your SMP server as a Linux process, optionally using a service manager for booting and restarts. -- For Ubuntu you can download a binary from [the latest release](https://github.com/simplex-chat/simplexmq/releases). +Notice that `smp-server` requires `openssl` as run-time dependency (it is used to generate server certificates during initialization). Install it with your packet manager: - If you're using other Linux distribution and the binary is incompatible with it, you can build from source using [Haskell stack](https://docs.haskellstack.org/en/stable/README/): +```sh +# For Ubuntu +apt update && apt install openssl +``` - ```shell - curl -sSL https://get.haskellstack.org/ | sh - ... - stack install - ``` +### Install binaries + +#### Using Docker + +On Linux, you can deploy smp server using Docker. + +1. Build your `smp-server` image: + + ```sh + git clone https://github.com/simplex-chat/simplexmq + cd simplex-chat + git checkout stable + DOCKER_BUILDKIT=1 docker build -t smp-server -f ./download.Dockerfile . + ``` +2. Run your Docker container: + ```sh + docker run -d \ + --name smp-server \ + -e addr="your_ip_or_domain" \ + -p 5223:5223 \ + -v ${PWD}/scripts/docker/config:/etc/opt/simplex \ + -v ${PWD}/scripts/docker/logs:/var/opt/simplex \ + smp-server + ``` + +#### Ubuntu + +For Ubuntu you can download a binary from [the latest release](https://github.com/simplex-chat/simplexmq/releases). + +### Build from source + +#### Using Docker + +> **Please note:** to build the app use source code from [stable branch](https://github.com/simplex-chat/simplexmq/tree/stable). + +On Linux, you can build smp server using Docker. + +1. Build your `smp-server` image: + + ```sh + git clone https://github.com/simplex-chat/simplexmq + cd simplexmq + git checkout stable + DOCKER_BUILDKIT=1 docker build -t smp-server -f ./build.Dockerfile . + ``` +2. Run your Docker container: + ```sh + docker run -d \ + --name smp-server \ + -e addr="your_ip_or_domain" \ + -p 5223:5223 \ + -v ${PWD}/scripts/docker/config:/etc/opt/simplex \ + -v ${PWD}/scripts/docker/logs:/var/opt/simplex \ + smp-server + ``` + +#### Using your distribution + +1. Install [Haskell GHCup](https://www.haskell.org/ghcup/), GHC 8.10.7 and cabal: + + ```sh + curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh + ghcup install ghc 8.10.7 + ghcup install cabal + ghcup set ghc 8.10.7 + ghcup set cabal + ``` + +2. Build the project: + + ```sh + git clone https://github.com/simplex-chat/simplexmq + cd simplexmq + git checkout stable + # On Ubuntu. Depending on your distribution, use your package manager to determine package names. + apt-get update && apt-get install -y build-essential libgmp3-dev zlib1g-dev + cabal update + cabal install + ``` - Initialize SMP server with `smp-server init [-l] -n ` or `smp-server init [-l] --ip ` - depending on how you initialize it, either FQDN or IP will be used for server's address. @@ -112,14 +189,6 @@ You can run your SMP server as a Linux process, optionally using a service manag See [this section](#smp-server) for more information. Run `smp-server -h` and `smp-server init -h` for explanation of commands and options. -Docker - -## Deploy SMP server with Docker - -SMP server could also be deployed using `Docker`. - -See: [`scripts/docker`](./scripts/docker/) - [Linode](https://cloud.linode.com/stackscripts/748014) ## Deploy SMP server on Linode diff --git a/scripts/docker/smp-server-build.Dockerfile b/build.Dockerfile similarity index 83% rename from scripts/docker/smp-server-build.Dockerfile rename to build.Dockerfile index 6cf1b4adc..c8cf42928 100644 --- a/scripts/docker/smp-server-build.Dockerfile +++ b/build.Dockerfile @@ -11,17 +11,15 @@ RUN curl https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup -o /usr/bin/ghc chmod +x /usr/bin/ghcup # Install ghc -RUN ghcup install ghc +RUN ghcup install ghc 8.10.7 # Install cabal RUN ghcup install cabal # Set both as default -RUN ghcup set ghc && \ +RUN ghcup set ghc 8.10.7 && \ ghcup set cabal -# Clone simplexmq repository -RUN git clone https://github.com/simplex-chat/simplexmq -# and cd to it -WORKDIR ./simplexmq +COPY . /project +WORKDIR /project # Adjust PATH ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:$PATH" @@ -41,7 +39,7 @@ RUN apt-get update && apt-get install -y openssl COPY --from=build /root/.cabal/bin/smp-server /usr/bin/smp-server # Copy our helper script -COPY ./entrypoint /usr/bin/entrypoint +COPY ./scripts/docker/entrypoint /usr/bin/entrypoint # Open smp-server listening port EXPOSE 5223 diff --git a/scripts/docker/smp-server-download.Dockerfile b/download.Dockerfile similarity index 91% rename from scripts/docker/smp-server-download.Dockerfile rename to download.Dockerfile index a87d45d40..48344c376 100644 --- a/scripts/docker/smp-server-download.Dockerfile +++ b/download.Dockerfile @@ -8,7 +8,7 @@ RUN curl -L https://github.com/simplex-chat/simplexmq/releases/latest/download/s chmod +x /usr/bin/smp-server # Copy our helper script -COPY ./entrypoint /usr/bin/entrypoint +COPY ./scripts/docker/entrypoint /usr/bin/entrypoint # Open smp-server listening port EXPOSE 5223 diff --git a/img/docker.svg b/img/docker.svg deleted file mode 100644 index c3690c1b7..000000000 --- a/img/docker.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/scripts/docker/README.md b/scripts/docker/README.md deleted file mode 100644 index bc1c89065..000000000 --- a/scripts/docker/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# smp-server docker container -0. Install `docker` to your host. - -1. Build your `smp-server` image: - - **Option 1** - Compile `smp-server` from source (stable branch): - ```sh - DOCKER_BUILDKIT=1 docker build -t smp-server -f smp-server-build.Dockerfile . - ``` - - **Option 2** - Download latest `smp-server` from [latest Github release](https://github.com/simplex-chat/simplexmq/releases/latest): - ```sh - DOCKER_BUILDKIT=1 docker build -t smp-server -f smp-server-download.Dockerfile . - ``` - -2. Run new docker container: -```sh -docker run -d \ - --name smp-server \ - -e addr="your_ip_or_domain" \ - -p 5223:5223 \ - -v ${PWD}/config:/etc/opt/simplex \ - -v ${PWD}/logs:/var/opt/simplex \ - smp-server -``` - -Configuration files and logs will be written to [`config`](./config) and [`logs`](./logs) folders respectively. diff --git a/scripts/docker/config/README.md b/scripts/docker/config/README.md deleted file mode 100644 index 50d25bd61..000000000 --- a/scripts/docker/config/README.md +++ /dev/null @@ -1 +0,0 @@ -smp-server configuration, certificate and fingerprint will be stored here diff --git a/scripts/docker/entrypoint b/scripts/docker/entrypoint index b1d4fd4aa..a761f339c 100755 --- a/scripts/docker/entrypoint +++ b/scripts/docker/entrypoint @@ -7,8 +7,8 @@ if [ ! -f "$confd/smp-server.ini" ]; then # If not, determine ip or domain case $addr in '') printf "Please specify \$addr environment variable.\n"; exit 1 ;; - *[a-zA-Z]*) smp-server init -l -n "$addr" ;; - *) smp-server init -l --ip "$addr" ;; + *[a-zA-Z]*) smp-server init -y -l -n "$addr" ;; + *) smp-server init -y -l --ip "$addr" ;; esac fi diff --git a/scripts/docker/logs/README.md b/scripts/docker/logs/README.md deleted file mode 100644 index f25e7ce01..000000000 --- a/scripts/docker/logs/README.md +++ /dev/null @@ -1 +0,0 @@ -smp-server general logs, stored messages and statistics (if enabled) will be stored here