From 10b7bf65e0d244b669213509b20894794dbf4c58 Mon Sep 17 00:00:00 2001 From: romeobuilderotti Date: Fri, 10 May 2024 13:40:31 +0300 Subject: [PATCH 1/2] Add docker compose --- README.md | 18 ++++++++++++++++++ docker-compose.yml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 docker-compose.yml diff --git a/README.md b/README.md index d946b8ec6..d24eceac2 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,24 @@ On Linux, you can deploy smp and xftp server using Docker. This will download im simplexchat/xftp-server:latest ``` +#### Using Docker Compose + +Alternatively you can use Docker Compose to deploy SMP and XFTP servers. In this case the servers store their data in docker volumes rather then the current directory. + +1. Download [docker-compose.yml](https://github.com/simplex-chat/simplexmq/blob/stable/docker-compose.yml): + +```sh +curl -O https://raw.githubusercontent.com/simplex-chat/simplexmq/stable/docker-compose.yml +``` + +2. Start the servers: + +```sh +ADDR=your_ip_or_domain.com PASS=password QUOTA=100gb docker-compose up -d +``` + +Environment variables are used only on the first start when server config files are created, you don't need to specify them on subsequent starts. + #### Using installation script **Please note** that currently, only Ubuntu distribution is supported. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..7655fe8b8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +# You must pass ADDR, PASS and QUOTA as environment variables to docker-compose like so: +# ADDR=your-ip-or-domain.com PASS=p@ssw0rd QUOTA=100gb docker-compose up -d +# Or replace the variables with your own values in the file below + +services: + smp: + image: simplexchat/smp-server:latest + environment: + ADDR: ${ADDR} + PASS: ${PASS} + ports: + - 5223:5223 + volumes: + - smp_config:/etc/opt/simplex + - smp_logs:/var/opt/simplex + + xftp: + image: simplexchat/xftp-server:latest + environment: + ADDR: ${ADDR} + QUOTA: ${QUOTA} + ports: + - 443:443 + volumes: + - xftp_config:/etc/opt/simplex-xftp + - xftp_logs:/var/opt/simplex-xftp + - xftp_files:/srv/xftp + +volumes: + smp_config: + smp_logs: + xftp_config: + xftp_logs: + xftp_files: From cf12b5dda12243eb8eceb7079fb639dcb8956111 Mon Sep 17 00:00:00 2001 From: romeobuilderotti Date: Fri, 10 May 2024 14:05:09 +0300 Subject: [PATCH 2/2] Clear apt cache, don't install extra packages --- Dockerfile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index e81db17c3..3649afe51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,9 @@ FROM ubuntu:${TAG} AS build ### Build stage # Install curl and git and simplexmq dependencies -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 +RUN apt-get update && \ + apt-get install -y --no-install-recommends curl git ca-certificates build-essential libgmp3-dev zlib1g-dev llvm-12 llvm-12-dev libnuma-dev libssl-dev && \ + rm -rf /var/lib/apt/lists/* # Specify bootstrap Haskell versions ENV BOOTSTRAP_HASKELL_GHC_VERSION=9.6.3 @@ -21,8 +23,8 @@ ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:$PATH" RUN ghcup set ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}" && \ ghcup set cabal "${BOOTSTRAP_HASKELL_CABAL_VERSION}" -COPY . /project WORKDIR /project +COPY . . ARG APP ARG APP_PORT @@ -33,7 +35,6 @@ RUN cabal update RUN cabal build exe:$APP # Create new path containing all files needed -RUN mkdir /final WORKDIR /final # Strip the binary from debug symbols to reduce size @@ -46,7 +47,9 @@ RUN bin=$(find /project/dist-newstyle -name "$APP" -type f -executable) && \ FROM ubuntu:${TAG} # Install OpenSSL dependency -RUN apt-get update && apt-get install -y openssl libnuma-dev +RUN apt-get update && \ + apt-get install -y --no-install-recommends openssl libnuma-dev && \ + rm -rf /var/lib/apt/lists/* # Copy compiled app from build stage COPY --from=build /final /usr/local/bin/