Skip to content

Commit aa26a55

Browse files
committed
Merge branch 'master' into stable
2 parents be81fe1 + 6e505f5 commit aa26a55

File tree

110 files changed

+8246
-4787
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+8246
-4787
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,61 +11,53 @@ on:
1111

1212
jobs:
1313
build:
14-
name: build-${{ matrix.os }}-${{ matrix.ghc }}
15-
runs-on: ${{ matrix.os }}
14+
name: "Ubuntu: ${{ matrix.os }}, GHC: ${{ matrix.ghc }}"
15+
env:
16+
apps: "smp-server xftp-server ntf-server xftp"
17+
runs-on: ubuntu-${{ matrix.os }}
1618
strategy:
1719
fail-fast: false
1820
matrix:
1921
include:
20-
- os: ubuntu-20.04
21-
platform_name: 20_04-x86-64
22+
- os: 22.04
2223
ghc: "8.10.7"
23-
- os: ubuntu-20.04
2424
platform_name: 20_04-x86-64
25+
- os: 20.04
26+
ghc: "9.6.3"
27+
platform_name: 20_04-x86-64
28+
- os: 22.04
2529
ghc: "9.6.3"
26-
- os: ubuntu-22.04
2730
platform_name: 22_04-x86-64
31+
- os: 24.04
2832
ghc: "9.6.3"
33+
platform_name: 24_04-x86-64
2934
steps:
3035
- name: Clone project
3136
uses: actions/checkout@v3
3237

33-
- name: Setup Haskell
34-
uses: haskell-actions/setup@v2
35-
with:
36-
ghc-version: ${{ matrix.ghc }}
37-
cabal-version: "3.10.1.0"
38-
39-
- name: Cache dependencies
40-
uses: actions/cache@v2
41-
with:
42-
path: |
43-
~/.cabal/store
44-
dist-newstyle
45-
key: ${{ matrix.os }}-${{ hashFiles('cabal.project', 'simplexmq.cabal') }}
38+
- name: Prepare image
39+
shell: bash
40+
run: docker build -f Dockerfile.build --build-arg TAG=${{ matrix.os }} --build-arg GHC=${{ matrix.ghc }} -t local .
4641

47-
- name: Build
42+
- name: Start container
4843
shell: bash
49-
run: cabal build --enable-tests
44+
run: docker run -t -d --name builder local
5045

51-
- name: Test
52-
timeout-minutes: 40
46+
- name: Build binaries
5347
shell: bash
54-
run: cabal test --test-show-details=direct
48+
run: docker exec -t -e apps="$apps" builder sh -c 'cabal build --enable-tests && mkdir /out && for i in $apps; do bin=$(find /project/dist-newstyle -name "$i" -type f -executable); strip "$bin"; chmod +x "$bin"; mv "$bin" /out/; done'
5549

56-
- name: Prepare binaries
50+
- name: Copy binaries from container and prepare them
5751
if: startsWith(github.ref, 'refs/tags/v')
5852
shell: bash
5953
run: |
60-
mv $(cabal list-bin smp-server) smp-server-ubuntu-${{ matrix.platform_name}}
61-
mv $(cabal list-bin ntf-server) ntf-server-ubuntu-${{ matrix.platform_name}}
62-
mv $(cabal list-bin xftp-server) xftp-server-ubuntu-${{ matrix.platform_name}}
63-
mv $(cabal list-bin xftp) xftp-ubuntu-${{ matrix.platform_name}}
54+
docker cp builder:/out .
55+
for i in $apps; do mv ./out/$i ./$i-ubuntu-${{ matrix.platform_name }}; done
6456
6557
- name: Build changelog
6658
if: startsWith(github.ref, 'refs/tags/v')
6759
id: build_changelog
68-
uses: mikepenz/release-changelog-builder-action@v1
60+
uses: mikepenz/release-changelog-builder-action@v5
6961
with:
7062
configuration: .github/changelog_conf.json
7163
failOnError: true
@@ -76,7 +68,7 @@ jobs:
7668

7769
- name: Create release
7870
if: startsWith(github.ref, 'refs/tags/v') && matrix.ghc != '8.10.7'
79-
uses: softprops/action-gh-release@v1
71+
uses: softprops/action-gh-release@v2
8072
with:
8173
body: |
8274
See full changelog [here](https://github.com/simplex-chat/simplexmq/blob/master/CHANGELOG.md).
@@ -86,10 +78,17 @@ jobs:
8678
prerelease: true
8779
files: |
8880
LICENSE
89-
smp-server-ubuntu-${{ matrix.platform_name}}
90-
ntf-server-ubuntu-${{ matrix.platform_name}}
91-
xftp-server-ubuntu-${{ matrix.platform_name}}
92-
xftp-ubuntu-${{ matrix.platform_name}}
81+
smp-server-ubuntu-${{ matrix.platform_name }}
82+
ntf-server-ubuntu-${{ matrix.platform_name }}
83+
xftp-server-ubuntu-${{ matrix.platform_name }}
84+
xftp-ubuntu-${{ matrix.platform_name }}
9385
fail_on_unmatched_files: true
9486
env:
9587
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
89+
- name: Test
90+
shell: bash
91+
run: |
92+
docker exec -t builder sh -c 'mv $(find /project/dist-newstyle -name "simplexmq-test" -type f -executable) /out/'
93+
docker cp builder:/out/simplexmq-test .
94+
./simplexmq-test

.github/workflows/docker-image.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ jobs:
1414
matrix:
1515
include:
1616
- app: smp-server
17-
app_port: 5223
17+
app_port: "443 5223"
1818
- app: xftp-server
19-
app_port: 443
19+
app_port: 443
2020
steps:
2121
- name: Clone project
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2323

2424
- name: Log in to Docker Hub
25-
uses: docker/login-action@v2
25+
uses: docker/login-action@v3
2626
with:
2727
username: ${{ secrets.DOCKERHUB_USERNAME }}
2828
password: ${{ secrets.DOCKERHUB_PASSWORD }}
2929

3030
- name: Extract metadata for Docker image
3131
id: meta
32-
uses: docker/metadata-action@v4
32+
uses: docker/metadata-action@v5
3333
with:
3434
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.app }}
3535
flavor: |
@@ -40,7 +40,7 @@ jobs:
4040
type=semver,pattern=v{{major}}
4141
4242
- name: Build and push Docker image
43-
uses: docker/build-push-action@v4
43+
uses: docker/build-push-action@v6
4444
with:
4545
push: true
4646
build-args: |

Dockerfile

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
ARG TAG=22.04
1+
# syntax=docker/dockerfile:1.7.0-labs
2+
ARG TAG=24.04
23

34
FROM ubuntu:${TAG} AS build
45

56
### Build stage
67

78
# Install curl and git and simplexmq dependencies
8-
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
9+
RUN apt-get update && apt-get install -y curl git build-essential libgmp3-dev zlib1g-dev llvm-18 llvm-18-dev libnuma-dev libssl-dev
910

1011
# Specify bootstrap Haskell versions
1112
ENV BOOTSTRAP_HASKELL_GHC_VERSION=9.6.3
12-
ENV BOOTSTRAP_HASKELL_CABAL_VERSION=3.10.1.0
13+
ENV BOOTSTRAP_HASKELL_CABAL_VERSION=3.12.1.0
14+
15+
# Do not install Stack
16+
ENV BOOTSTRAP_HASKELL_INSTALL_NO_STACK=true
17+
ENV BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=true
1318

1419
# Install ghcup
1520
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 sh
@@ -21,26 +26,42 @@ ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:$PATH"
2126
RUN ghcup set ghc "${BOOTSTRAP_HASKELL_GHC_VERSION}" && \
2227
ghcup set cabal "${BOOTSTRAP_HASKELL_CABAL_VERSION}"
2328

24-
COPY . /project
29+
# Copy only the source code
30+
COPY apps /project/apps/
31+
COPY cbits /project/cbits/
32+
COPY src /project/src/
33+
34+
COPY cabal.project Setup.hs simplexmq.cabal LICENSE /project
35+
2536
WORKDIR /project
2637

38+
# Debug
39+
#ARG CACHEBUST=1
40+
41+
#ADD --chmod=755 https://github.com/MShekow/directory-checksum/releases/download/v1.4.6/directory-checksum_1.4.6_linux_amd64 /usr/local/bin/directory-checksum
42+
#RUN directory-checksum --max-depth 2 .
43+
44+
# Set build arguments and check if they exist
2745
ARG APP
28-
ARG APP_PORT
29-
RUN if [ -z "$APP" ] || [ -z "$APP_PORT" ]; then printf "Please spcify \$APP and \$APP_PORT build-arg.\n"; exit 1; fi
46+
RUN if [ -z "$APP" ]; then printf "Please spcify \$APP build-arg.\n"; exit 1; fi
3047

3148
# Compile app
3249
RUN cabal update
3350
RUN cabal build exe:$APP
3451

52+
# Copy scripts
53+
COPY scripts /project/scripts/
54+
3555
# Create new path containing all files needed
3656
RUN mkdir /final
3757
WORKDIR /final
3858

3959
# Strip the binary from debug symbols to reduce size
40-
RUN bin=$(find /project/dist-newstyle -name "$APP" -type f -executable) && \
60+
RUN bin="$(find /project/dist-newstyle -name "$APP" -type f -executable)" && \
4161
mv "$bin" ./ && \
4262
strip ./"$APP" &&\
43-
mv /project/scripts/docker/entrypoint-"$APP" ./entrypoint
63+
mv /project/scripts/docker/entrypoint-"$APP" ./entrypoint &&\
64+
mv /project/scripts/main/simplex-servers-stopscript ./simplex-servers-stopscript
4465

4566
### Final stage
4667
FROM ubuntu:${TAG}
@@ -53,6 +74,8 @@ COPY --from=build /final /usr/local/bin/
5374

5475
# Open app listening port
5576
ARG APP_PORT
77+
RUN if [ -z "$APP_PORT" ]; then printf "Please spcify \$APP_PORT build-arg.\n"; exit 1; fi
78+
5679
EXPOSE $APP_PORT
5780

5881
# simplexmq requires using SIGINT to correctly preserve undelivered messages and restore them on restart

Dockerfile.build

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# syntax=docker/dockerfile:1.7.0-labs
2+
ARG TAG=24.04
3+
FROM ubuntu:${TAG} AS build
4+
5+
### Build stage
6+
7+
ARG GHC=9.6.3
8+
ARG CABAL=3.14.1.1
9+
10+
# Install curl, git and and simplexmq dependencies
11+
RUN apt-get update && apt-get install -y curl git sqlite3 libsqlite3-dev build-essential libgmp3-dev zlib1g-dev llvm llvm-dev libnuma-dev libssl-dev
12+
13+
# Specify bootstrap Haskell versions
14+
ENV BOOTSTRAP_HASKELL_GHC_VERSION=${GHC}
15+
ENV BOOTSTRAP_HASKELL_CABAL_VERSION=${CABAL}
16+
17+
# Do not install Stack
18+
ENV BOOTSTRAP_HASKELL_INSTALL_NO_STACK=true
19+
ENV BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=true
20+
21+
# Install ghcup
22+
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 sh
23+
24+
# Adjust PATH
25+
ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:$PATH"
26+
27+
# Set both as default
28+
RUN ghcup set ghc "${GHC}" && \
29+
ghcup set cabal "${CABAL}"
30+
31+
# Copy only the source code
32+
COPY apps /project/apps/
33+
COPY cbits /project/cbits/
34+
COPY src /project/src/
35+
COPY tests /project/tests/
36+
37+
COPY cabal.project Setup.hs simplexmq.cabal LICENSE /project
38+
39+
WORKDIR /project
40+
41+
# Compile app
42+
RUN cabal update

cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ packages: .
44
-- packages: . ../http2
55
-- packages: . ../network-transport
66

7+
-- uncomment two sections below to run tests with coverage
78
-- package *
89
-- coverage: True
910
-- library-coverage: True
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: SimpleX Chat - smp-server
2+
3+
services:
4+
oneshot:
5+
image: ubuntu:latest
6+
environment:
7+
CADDYCONF: |
8+
${CADDY_OPTS:-}
9+
10+
http://{$$ADDR} {
11+
redir https://{$$ADDR}{uri} permanent
12+
}
13+
14+
{$$ADDR}:8443 {
15+
tls {
16+
key_type rsa4096
17+
}
18+
}
19+
command: sh -c 'if [ ! -f /etc/caddy/Caddyfile ]; then printf "$${CADDYCONF}" > /etc/caddy/Caddyfile; fi'
20+
volumes:
21+
- ./caddy_conf:/etc/caddy
22+
23+
caddy:
24+
image: caddy:latest
25+
depends_on:
26+
oneshot:
27+
condition: service_completed_successfully
28+
cap_add:
29+
- NET_ADMIN
30+
environment:
31+
ADDR: ${ADDR?"Please specify the domain."}
32+
volumes:
33+
- ./caddy_conf:/etc/caddy
34+
- caddy_data:/data
35+
- caddy_config:/config
36+
ports:
37+
- 80:80
38+
restart: unless-stopped
39+
healthcheck:
40+
test: "test -d /data/caddy/certificates/${CERT_PATH:-acme-v02.api.letsencrypt.org-directory}/${ADDR} || exit 1"
41+
interval: 1s
42+
retries: 60
43+
44+
smp-server:
45+
image: ${SIMPLEX_IMAGE:-simplexchat/smp-server:latest}
46+
depends_on:
47+
caddy:
48+
condition: service_healthy
49+
environment:
50+
ADDR: ${ADDR?"Please specify the domain."}
51+
PASS: ${PASS:-}
52+
volumes:
53+
- ./smp_configs:/etc/opt/simplex
54+
- ./smp_state:/var/opt/simplex
55+
- type: volume
56+
source: caddy_data
57+
target: /certificates
58+
volume:
59+
subpath: "caddy/certificates/${CERT_PATH:-acme-v02.api.letsencrypt.org-directory}/${ADDR}"
60+
ports:
61+
- 443:443
62+
- 5223:5223
63+
restart: unless-stopped
64+
65+
volumes:
66+
caddy_data:
67+
caddy_config:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: SimpleX Chat - smp-server
2+
3+
services:
4+
smp-server:
5+
image: ${SIMPLEX_IMAGE:-simplexchat/smp-server:latest}
6+
environment:
7+
WEB_MANUAL: ${WEB_MANUAL:-1}
8+
ADDR: ${ADDR?"Please specify the domain."}
9+
PASS: ${PASS:-}
10+
volumes:
11+
- ./smp_configs:/etc/opt/simplex
12+
- ./smp_state:/var/opt/simplex
13+
ports:
14+
- 5223:5223
15+
restart: unless-stopped
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Mandatory
2+
ADDR=your_ip_or_addr
3+
4+
# Optional
5+
#PASS='123123'
6+
#WEB_MANUAL=1
7+
8+
# Debug
9+
#SIMPLEX_SMP_IMAGE=smp-server-dev
10+
#CERT_PATH=acme-staging-v02.api.letsencrypt.org-directory
11+
#CADDY_OPTS='{\n acme_ca https://acme-staging-v02.api.letsencrypt.org/directory\n}'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Mandatory
2+
ADDR=your_ip_or_addr
3+
QUOTA=120gb
4+
5+
# Optional
6+
#PASS='123123'
7+
8+
# Debug
9+
#SIMPLEX_XFTP_IMAGE=xftp-server-dev

0 commit comments

Comments
 (0)