From d876033c1ab454d2c2b21ce9750bbde4de03e395 Mon Sep 17 00:00:00 2001 From: mdecimus Date: Fri, 12 Apr 2024 16:35:00 +0200 Subject: [PATCH] Use cross-compilation for CI, build the Docker image from source (#85) --- .github/workflows/build.yml | 533 +++++++++++++--------------------- .github/workflows/docker.yml | 120 -------- .github/workflows/test.yml | 81 ++---- CHANGELOG.md | 14 + Cargo.lock | 202 +++++++------ Dockerfile | 47 ++- crates/cli/Cargo.toml | 2 +- crates/common/Cargo.toml | 2 +- crates/directory/Cargo.toml | 2 +- crates/imap/Cargo.toml | 2 +- crates/jmap/Cargo.toml | 2 +- crates/main/Cargo.toml | 2 +- crates/managesieve/Cargo.toml | 2 +- crates/nlp/Cargo.toml | 2 +- crates/smtp/Cargo.toml | 2 +- crates/store/Cargo.toml | 2 +- crates/utils/Cargo.toml | 2 +- 17 files changed, 391 insertions(+), 628 deletions(-) delete mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e38d0ea8..407296d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,351 +1,230 @@ +# Credits: https://github.com/33KK + name: Build on: workflow_dispatch: pull_request: push: - tags: - - "v*.*.*" - -env: - REGISTRY_IMAGE: stalwartlabs/mail-server + tags: ["v*.*.*"] + branches: ["main"] jobs: build: - name: Building for ${{ matrix.target }} on ${{ matrix.host_os }} - runs-on: ${{ matrix.host_os }} - if: '!cancelled()' - strategy: - matrix: - include: - - target: x86_64-unknown-linux-gnu - host_os: ubuntu-20.04 - - target: x86_64-apple-darwin - host_os: macos-latest - - target: x86_64-pc-windows-msvc - host_os: windows-2022 - #- target: aarch64-unknown-linux-gnu - # host_os: ubuntu-20.04 - #- target: x86_64-unknown-linux-musl - # host_os: ubuntu-20.04 - #- target: aarch64-unknown-linux-musl - # host_os: ubuntu-20.04 - #- target: aarch64-apple-darwin - # host_os: macos-latest - #- target: aarch64-pc-windows-msvc - # host_os: windows-2022 - #- target: aarch64-pc-windows-msvc - # host_os: windows-2022 - #- target: arm-unknown-linux-musleabihf - # host_os: ubuntu-20.04 - #- target: arm-unknown-linux-gnueabihf - # host_os: ubuntu-20.04 - #- target: armv7-unknown-linux-musleabihf - # host_os: ubuntu-20.04 - #- target: armv7-unknown-linux-gnueabihf - # host_os: ubuntu-20.04 + name: Build / ${{matrix.target}} - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - persist-credentials: false + runs-on: ${{matrix.host_os}} - - name: Install dependencies (Linux) - if: ${{ contains(matrix.host_os, 'ubuntu') }} - run: | - sudo apt-get update -y - sudo apt-get install -yq protobuf-compiler wget - wget https://github.com/apple/foundationdb/releases/download/7.1.0/foundationdb-clients_7.1.0-1_amd64.deb - sudo dpkg -i --force-architecture foundationdb-clients_7.1.0-1_amd64.deb - - - name: Install dependencies (MacOs) - if: ${{ contains(matrix.host_os, 'macos') }} - run: | - brew install protobuf - brew install wget - wget https://github.com/apple/foundationdb/releases/download/7.1.32/FoundationDB-7.1.32_x86_64.pkg - sudo installer -allowUntrusted -dumplog -pkg FoundationDB-7.1.32_x86_64.pkg -target / - - - name: Install dependencies (Windows) - if: ${{ contains(matrix.host_os, 'windows') }} - uses: arduino/setup-protoc@v1 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - override: true - target: ${{ matrix.target }} - toolchain: stable - - - name: Rust Cache - uses: Swatinem/rust-cache@v2 - with: - key: ${{ matrix.host_os }}-${{ matrix.target }}-mail - - - name: Building binary (Unix version) - if: ${{ !contains(matrix.host_os, 'windows') }} - run: | - cargo build -p mail-server --target=${{ matrix.target }} --no-default-features --features "foundationdb elastic s3 redis" --release - cd target/${{ matrix.target }}/release && tar czvf ../../../stalwart-mail-foundationdb-${{ matrix.target }}.tar.gz stalwart-mail && cd - - cargo build -p mail-server -p stalwart-cli --target=${{ matrix.target }} --release - cd target/${{ matrix.target }}/release - tar czvf ../../../stalwart-mail-${{ matrix.target }}.tar.gz stalwart-mail - tar czvf ../../../stalwart-cli-${{ matrix.target }}.tar.gz stalwart-cli - cd - - - - name: Building binary (Windows version) - if: ${{ contains(matrix.host_os, 'windows') }} - run: | - cargo build -p mail-server -p stalwart-cli --target=${{ matrix.target }} --release - cd target/${{ matrix.target }}/release - 7z a ../../../stalwart-mail-${{ matrix.target }}.zip stalwart-mail.exe - 7z a ../../../stalwart-cli-${{ matrix.target }}.zip stalwart-cli.exe - cd - - - - name: Publish Release - if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@v1 - with: - files: 'stalwart-*' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - cross_build_tools: - runs-on: ubuntu-latest - name: Building tools for ${{ matrix.target }} on ${{ matrix.distro }} - if: '!cancelled()' - - strategy: - matrix: - include: - - arch: aarch64 - distro: ubuntu20.04 - target: aarch64-unknown-linux-gnu - steps: - - uses: actions/checkout@v3 - - uses: uraimo/run-on-arch-action@v2 - name: Build artifact - id: build - with: - arch: ${{ matrix.arch }} - distro: ${{ matrix.distro }} - - # Not required, but speeds up builds - githubToken: ${{ github.token }} - - # Create an artifacts directory - setup: | - mkdir -p "${PWD}/artifacts" - - # Mount the artifacts directory as /artifacts in the container - dockerRunArgs: | - --volume "${PWD}/artifacts:/artifacts" - - # Pass some environment variables to the container - env: | - target: ${{ matrix.target }} - - # The shell to run commands with in the container - shell: /bin/sh - - install: | - apt-get update -yq - apt-get install -yq build-essential cmake wget curl - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal - - run: | - export PATH="$HOME/.cargo/bin:$PATH" - cargo build -p stalwart-cli --target=${target} --release - cd target/${target}/release - tar czvf /artifacts/stalwart-cli-${target}.tar.gz stalwart-cli - cd - - - - name: Move packages - run: | - mv ${PWD}/artifacts/* . - - - name: Publish Release - if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@v1 - with: - files: 'stalwart-*' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - cross_build: - runs-on: ubuntu-latest - name: Building for ${{ matrix.target }} on ${{ matrix.distro }} - if: '!cancelled()' - - strategy: - matrix: - include: - - arch: aarch64 - distro: ubuntu20.04 - target: aarch64-unknown-linux-gnu - steps: - - uses: actions/checkout@v3 - - uses: uraimo/run-on-arch-action@v2 - name: Build artifact - id: build - with: - arch: ${{ matrix.arch }} - distro: ${{ matrix.distro }} - - # Not required, but speeds up builds - githubToken: ${{ github.token }} - - # Create an artifacts directory - setup: | - mkdir -p "${PWD}/artifacts" - - # Mount the artifacts directory as /artifacts in the container - dockerRunArgs: | - --volume "${PWD}/artifacts:/artifacts" - - # Pass some environment variables to the container - env: | - target: ${{ matrix.target }} - - # The shell to run commands with in the container - shell: /bin/sh - - install: | - apt-get update -yq - apt-get install -yq build-essential cmake protobuf-compiler wget curl clang libclang-dev - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal - - run: | - export PATH="$HOME/.cargo/bin:$PATH" - cargo build -p mail-server --target=${target} --release - cd target/${target}/release - tar czvf /artifacts/stalwart-mail-${target}.tar.gz stalwart-mail - cd - - - - name: Move packages - run: | - mv ${PWD}/artifacts/* . - - - name: Publish Release - if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@v1 - with: - files: 'stalwart-*' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - build_docker: - needs: - - build - - cross_build - - cross_build_tools - name: Build Docker image for ${{ matrix.platform }} - runs-on: ubuntu-latest - if: '!cancelled()' strategy: fail-fast: false matrix: - platform: - - linux/amd64 - - linux/arm64 + include: + - target: aarch64-unknown-linux-gnu + host_os: ubuntu-20.04 + use_cross: true + - target: armv7-unknown-linux-gnueabihf + host_os: ubuntu-20.04 + use_cross: true + #- target: arm-unknown-linux-gnueabihf + # host_os: ubuntu-20.04 + # use_cross: true + - target: x86_64-unknown-linux-gnu + host_os: ubuntu-20.04 + use_cross: false + + - target: aarch64-unknown-linux-musl + host_os: ubuntu-20.04 + use_cross: true + #- target: armv7-unknown-linux-musleabihf + # host_os: ubuntu-20.04 + # use_cross: true + #- target: arm-unknown-linux-musleabihf + # host_os: ubuntu-20.04 + # use_cross: true + - target: x86_64-unknown-linux-musl + host_os: ubuntu-20.04 + use_cross: true + + - target: aarch64-apple-darwin + host_os: macos-latest + use_cross: false + - target: x86_64-apple-darwin + host_os: macos-latest + use_cross: false + + # FIXME: waiting for ldap3 and hickory-resolver bump to ring 0.17.x + #- target: aarch64-pc-windows-msvc + # host_os: windows-2022 + # use_cross: false + - target: x86_64-pc-windows-msvc + host_os: windows-2022 + use_cross: false + steps: - - - name: Prepare + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Dependencies (Linux) + if: startsWith(matrix.host_os, 'ubuntu') + shell: bash run: | - platform=${{ matrix.platform }} - echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV - - - name: Checkout - uses: actions/checkout@v3 - - - name: Docker meta + sudo apt-get update + sudo apt-get install -yq build-essential + + - name: Install FoundationDB (x86_64-unknown-linux-gnu) + if: matrix.target == 'x86_64-unknown-linux-gnu' + run: | + curl -LO https://github.com/apple/foundationdb/releases/download/7.1.0/foundationdb-clients_7.1.0-1_amd64.deb + sudo dpkg -i --force-architecture foundationdb-clients_7.1.0-1_amd64.deb + echo "USE_FOUNDATIONDB=1" >> "$GITHUB_ENV" + + - name: Install FoundationDB (x86_64-apple-darwin) + if: matrix.target == 'x86_64-apple-darwin' + run: | + curl -LO https://github.com/apple/foundationdb/releases/download/7.1.34/FoundationDB-7.1.34_x86_64.pkg + sudo installer -allowUntrusted -dumplog -pkg FoundationDB-7.1.34_x86_64.pkg -target / + echo "USE_FOUNDATIONDB=1" >> "$GITHUB_ENV" + + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + with: + key: ${{matrix.host_os}}-${{matrix.target}}-mail + + - name: Install Cross + if: matrix.use_cross == true + uses: baptiste0928/cargo-install@v2 + with: + crate: cross + git: https://github.com/cross-rs/cross + + - name: Build + shell: bash + run: | + set -eux + + target="${{matrix.target}}" + rustup target add "${target}" + + root="${PWD}" + mkdir artifacts archives + ext="${{startsWith(matrix.host_os, 'windows') == true && '.exe' || ''}}" + + # Workaround a Windows moment + export PATH="/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:$PATH" + + build() { + ${{matrix.env}} ${{matrix.use_cross == true && 'cross' || 'cargo'}} build --release --target "${target}" "$@" + } + + artifact() { + local file="${1}${ext}" + local name="${root}/archives/${2:-$1}-${target}" + if [ "${ext}" = ".exe" ]; then + 7z a "${name}.zip" "${file}" + else + tar czvf "${name}.tar.gz" "${file}" + fi + mv "${file}" "${root}/artifacts/${2:-$1}" + } + + mkdir -p "${root}/target/${target}/release" && cd "$_" + + if [ "${USE_FOUNDATIONDB:-0}" = 1 ]; then + build -p mail-server --features foundationdb + else + build -p mail-server + fi + build -p stalwart-cli + + artifact stalwart-mail + artifact stalwart-cli + + - name: Upload Archives + uses: actions/upload-artifact@v3 + with: + name: archives + path: ./archives + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{matrix.target}} + path: ./artifacts + + release: + name: Release + + if: github.event_name == 'push' + needs: build + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Download Artifacts + uses: actions/download-artifact@v3 + with: + name: archives + path: ./archives + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: ./archives/* + prerelease: ${{!startsWith(github.ref, 'refs/tags/') == true && true || null}} + tag_name: ${{!startsWith(github.ref, 'refs/tags/') == true && 'nightly' || null}} + + + docker_build: + name: Docker Build + + if: github.event_name == 'push' + runs-on: ubuntu-latest + + permissions: + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set Up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Log In to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{github.repository_owner}} + password: ${{github.token}} + + - name: Log In to DockerHub + uses: docker/login-action@v2 + with: + username: ${{secrets.DOCKERHUB_USERNAME}} + password: ${{secrets.DOCKERHUB_TOKEN}} + + - name: Extract Metadata for Docker id: meta uses: docker/metadata-action@v4 with: - images: ${{ env.REGISTRY_IMAGE }} + images: | + ${{github.repository}} + ghcr.io/${{github.repository}} tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push by digest + type=ref,event=tag + type=edge,branch=main + + - name: Build and Push Docker Images id: build uses: docker/build-push-action@v4 with: context: . - platforms: ${{ matrix.platform }} - labels: ${{ steps.meta.outputs.labels }} - outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true - #cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }} - #cache-to: type=registry,ref=s${{ env.REGISTRY_IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }},mode=max - cache-from: type=gha,scope=build-${{ env.PLATFORM_PAIR }} - cache-to: type=gha,scope=build-${{ env.PLATFORM_PAIR }} - - - name: Export digest - run: | - mkdir -p /tmp/digests - digest="${{ steps.build.outputs.digest }}" - touch "/tmp/digests/${digest#sha256:}" - - - name: Upload digest - uses: actions/upload-artifact@v3 - with: - name: digests - path: /tmp/digests/* - if-no-files-found: error - retention-days: 1 - - merge_docker: - name: Merge and push Docker manifest - runs-on: ubuntu-latest - needs: - - build_docker - steps: - - - name: Download digests - uses: actions/download-artifact@v3 - with: - name: digests - path: /tmp/digests - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY_IMAGE }} - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Create manifest list and push - working-directory: /tmp/digests - run: | - docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - - - name: Inspect image - run: | - docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{steps.meta.outputs.tags}} + labels: ${{steps.meta.outputs.labels}} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 1d22df6d..00000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,120 +0,0 @@ -name: Docker Build - -on: - workflow_dispatch: - pull_request: - -env: - REGISTRY_IMAGE: stalwartlabs/mail-server - -jobs: - build_docker: - name: Build Docker image for ${{ matrix.platform }} - runs-on: ubuntu-latest - if: '!cancelled()' - strategy: - fail-fast: false - matrix: - platform: - - linux/amd64 - - linux/arm64 - steps: - - - name: Prepare - run: | - platform=${{ matrix.platform }} - echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV - - - name: Checkout - uses: actions/checkout@v3 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY_IMAGE }} - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push by digest - id: build - uses: docker/build-push-action@v4 - with: - context: . - platforms: ${{ matrix.platform }} - labels: ${{ steps.meta.outputs.labels }} - outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true - #cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }} - #cache-to: type=registry,ref=s${{ env.REGISTRY_IMAGE }}:buildcache-${{ env.PLATFORM_PAIR }},mode=max - cache-from: type=gha,scope=build-${{ env.PLATFORM_PAIR }} - cache-to: type=gha,scope=build-${{ env.PLATFORM_PAIR }} - - - name: Export digest - run: | - mkdir -p /tmp/digests - digest="${{ steps.build.outputs.digest }}" - touch "/tmp/digests/${digest#sha256:}" - - - name: Upload digest - uses: actions/upload-artifact@v3 - with: - name: digests - path: /tmp/digests/* - if-no-files-found: error - retention-days: 1 - - merge_docker: - name: Merge and push Docker manifest - runs-on: ubuntu-latest - needs: - - build_docker - steps: - - - name: Download digests - uses: actions/download-artifact@v3 - with: - name: digests - path: /tmp/digests - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY_IMAGE }} - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Create manifest list and push - working-directory: /tmp/digests - run: | - docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - - - name: Inspect image - run: | - docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3065b08a..8a02fefa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,8 +4,8 @@ on: workflow_dispatch: pull_request: push: - tags: - - '*' + tags: ["v*.*.*"] + branches: ["*"] jobs: style: @@ -13,98 +13,55 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - components: rustfmt - profile: minimal - override: true - - - name: cargo fmt -- --check - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check + - name: Check Style + run: cargo fmt --all --check test: name: Test - needs: [style] + needs: style runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Install dependencies run: | sudo apt-get update -y - sudo apt-get install -yq protobuf-compiler - wget https://github.com/glauth/glauth/releases/download/v2.2.0/glauth-linux-arm64 + curl -LO https://github.com/glauth/glauth/releases/download/v2.2.0/glauth-linux-arm64 chmod a+rx glauth-linux-arm64 nohup ./glauth-linux-arm64 -c tests/resources/ldap.cfg & - wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio_20230629051228.0.0_amd64.deb -O minio.deb + curl -Lo minio.deb https://dl.min.io/server/minio/release/linux-amd64/archive/minio_20230629051228.0.0_amd64.deb sudo dpkg -i minio.deb mkdir ~/minio nohup minio server ~/minio --console-address :9090 & - wget https://dl.min.io/client/mc/release/linux-amd64/mc + curl -LO https://dl.min.io/client/mc/release/linux-amd64/mc chmod a+rx mc ./mc alias set myminio http://localhost:9000 minioadmin minioadmin ./mc mb tmp - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true + - name: Rust Cache + uses: Swatinem/rust-cache@v2 - name: JMAP Protocol Tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path=crates/jmap-proto/Cargo.toml + run: cargo test -p jmap_proto -- --nocapture - name: IMAP Protocol Tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path=crates/imap-proto/Cargo.toml + run: cargo test -p imap_proto -- --nocapture - name: Full-text search Tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path=crates/store/Cargo.toml - - #- name: Store Tests - # uses: actions-rs/cargo@v1 - # with: - # command: test - # args: --manifest-path=tests/Cargo.toml store -- --nocapture + run: cargo test -p store -- --nocapture - name: Directory Tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path=tests/Cargo.toml directory -- --nocapture + run: cargo test -p tests directory -- --nocapture - name: SMTP Tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path=tests/Cargo.toml smtp -- --nocapture + run: cargo test -p tests smtp -- --nocapture - name: IMAP Tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path=tests/Cargo.toml imap -- --nocapture + run: cargo test -p tests imap -- --nocapture - name: JMAP Tests - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path=tests/Cargo.toml jmap -- --nocapture + run: cargo test -p tests jmap -- --nocapture diff --git a/CHANGELOG.md b/CHANGELOG.md index 60100d14..03520774 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.7.1] - 2024-04-12 + +To upgrade replace the `stalwart-mail` binary. + +## Added +- Make initial admin password configurable via env (#311) + +### Changed +- WebAdmin download URL. + +### Fixed +- Remove ASN.1 DER structure from DKIM ED25519 public keys. +- Filter out invalid timestamps on log entries. + ## [0.7.0] - 2024-04-09 This version uses a different database layout and introduces multiple breaking changes in the configuration files. Please read the [UPGRADING.md](UPGRADING.md) file for more information on how to upgrade from previous versions. diff --git a/Cargo.lock b/Cargo.lock index 0321403f..4de59e42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "android-tzdata" @@ -173,9 +173,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "arc-swap" @@ -296,9 +296,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86a9249d1447a85f95810c620abea82e001fe58a31713fcce614caf52499f905" +checksum = "07dbbf24db18d609b1462965249abdf49129ccad073ec257da372adc83259c60" dependencies = [ "flate2", "futures-core", @@ -342,9 +342,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.79" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", @@ -694,9 +694,9 @@ dependencies = [ [[package]] name = "buffered-reader" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b9b0a25eb06e83579bc985d836e1e3b957a7201301b48538764d2b2e78090d4" +checksum = "cd098763fdb64579407a8c83cf0d751e6d4a7e161d0114c89cc181a2ca760ec8" dependencies = [ "lazy_static", "libc", @@ -704,9 +704,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytecheck" @@ -799,9 +799,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.90" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" dependencies = [ "jobserver", "libc", @@ -971,9 +971,9 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "combine" -version = "4.6.6" +version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" dependencies = [ "bytes", "futures-core", @@ -985,7 +985,7 @@ dependencies = [ [[package]] name = "common" -version = "0.7.0" +version = "0.7.1" dependencies = [ "ahash 0.8.11", "arc-swap", @@ -1017,10 +1017,10 @@ dependencies = [ "pwhash", "rcgen 0.12.1", "regex", - "reqwest 0.12.2", + "reqwest 0.12.3", "ring 0.17.8", "rustls 0.22.3", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "rustls-pki-types", "serde", "serde_json", @@ -1496,7 +1496,7 @@ dependencies = [ [[package]] name = "directory" -version = "0.7.0" +version = "0.7.1" dependencies = [ "ahash 0.8.11", "argon2", @@ -1764,9 +1764,9 @@ checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -2165,9 +2165,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -2211,9 +2211,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -2230,9 +2230,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ee2dd2e4f378392eeff5d51618cd9a63166a2513846bbc55f21cfacd9199d4" +checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" dependencies = [ "bytes", "fnv", @@ -2493,7 +2493,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.3.25", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "httparse", @@ -2516,7 +2516,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.3", + "h2 0.4.4", "http 1.1.0", "http-body 1.0.0", "httparse", @@ -2657,7 +2657,7 @@ checksum = "029d73f573d8e8d63e6d5020011d3255b28c3ba85d6cf870a07184ed23de9284" [[package]] name = "imap" -version = "0.7.0" +version = "0.7.1" dependencies = [ "ahash 0.8.11", "common", @@ -2673,7 +2673,7 @@ dependencies = [ "parking_lot", "rand", "rustls 0.22.3", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "store", "tokio", "tokio-rustls 0.25.0", @@ -2763,7 +2763,7 @@ dependencies = [ "socket2", "widestring", "windows-sys 0.48.0", - "winreg", + "winreg 0.50.0", ] [[package]] @@ -2853,7 +2853,7 @@ dependencies = [ [[package]] name = "jmap" -version = "0.7.0" +version = "0.7.1" dependencies = [ "aes", "aes-gcm", @@ -2889,7 +2889,7 @@ dependencies = [ "rasn", "rasn-cms", "rasn-pkix", - "reqwest 0.12.2", + "reqwest 0.12.3", "rev_lines", "rsa", "sequoia-openpgp", @@ -2947,9 +2947,9 @@ dependencies = [ [[package]] name = "jobserver" -version = "0.1.28" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +checksum = "f08474e32172238f2827bd160c67871cdb2801430f65c3979184dc362e3ca118" dependencies = [ "libc", ] @@ -3223,7 +3223,7 @@ dependencies = [ "rand", "ring 0.17.8", "rsa", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "serde", "serde_json", "zip", @@ -3267,7 +3267,7 @@ dependencies = [ [[package]] name = "mail-server" -version = "0.7.0" +version = "0.7.1" dependencies = [ "common", "directory", @@ -3285,7 +3285,7 @@ dependencies = [ [[package]] name = "managesieve" -version = "0.7.0" +version = "0.7.1" dependencies = [ "ahash 0.8.11", "bincode", @@ -3300,7 +3300,7 @@ dependencies = [ "md5", "parking_lot", "rustls 0.22.3", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "sieve-rs", "store", "tokio", @@ -3440,9 +3440,9 @@ dependencies = [ [[package]] name = "mysql-common-derive" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c60492b5eb751e55b42d716b6b26dceb66767996cd7a5560a842fbf613ca2e92" +checksum = "afe0450cc9344afff34915f8328600ab5ae19260802a334d0f72d2d5bdda3bfe" dependencies = [ "darling 0.20.8", "heck 0.4.1", @@ -3479,7 +3479,7 @@ dependencies = [ "pin-project", "rand", "rustls 0.22.3", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "serde", "serde_json", "socket2", @@ -3553,7 +3553,7 @@ dependencies = [ [[package]] name = "nlp" -version = "0.7.0" +version = "0.7.1" dependencies = [ "ahash 0.8.11", "bincode", @@ -3966,11 +3966,11 @@ dependencies = [ [[package]] name = "pem" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "serde", ] @@ -4277,9 +4277,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" +checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" dependencies = [ "bytes", "prost-derive", @@ -4287,12 +4287,12 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" dependencies = [ "anyhow", - "itertools 0.11.0", + "itertools 0.12.1", "proc-macro2", "quote", "syn 2.0.58", @@ -4370,9 +4370,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -4514,9 +4514,9 @@ dependencies = [ [[package]] name = "rcgen" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa96feb4d337a43eae1b39b6d4cafc2860a46cf9cec6f1e65294244ece65e348" +checksum = "54077e1872c46788540de1ea3d7f4ccb1983d12f9aa909b234468676c1a36779" dependencies = [ "pem", "ring 0.17.8", @@ -4527,9 +4527,9 @@ dependencies = [ [[package]] name = "redis" -version = "0.25.2" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d64e978fd98a0e6b105d066ba4889a7301fca65aeac850a877d8797343feeb" +checksum = "6472825949c09872e8f2c50bde59fcefc17748b6be5c90fd67cd8b4daca73bfd" dependencies = [ "async-trait", "bytes", @@ -4544,7 +4544,7 @@ dependencies = [ "rand", "rustls 0.22.3", "rustls-native-certs 0.7.0", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "rustls-pki-types", "ryu", "sha1_smol", @@ -4641,7 +4641,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2 0.3.25", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.28", @@ -4670,21 +4670,21 @@ dependencies = [ "wasm-streams", "web-sys", "webpki-roots 0.25.4", - "winreg", + "winreg 0.50.0", ] [[package]] name = "reqwest" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d66674f2b6fb864665eea7a3c1ac4e3dfacd2fda83cf6f935a612e01b0e3338" +checksum = "3e6cc1e89e689536eb5aeede61520e874df5a4707df811cd5da4aa5fbb2aae19" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "bytes", "futures-channel", "futures-core", "futures-util", - "h2 0.4.3", + "h2 0.4.4", "http 1.1.0", "http-body 1.0.0", "http-body-util", @@ -4700,7 +4700,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.22.3", - "rustls-pemfile 1.0.4", + "rustls-pemfile 2.1.2", "rustls-pki-types", "serde", "serde_json", @@ -4714,7 +4714,7 @@ dependencies = [ "wasm-bindgen-futures", "web-sys", "webpki-roots 0.26.1", - "winreg", + "winreg 0.52.0", ] [[package]] @@ -5066,7 +5066,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" dependencies = [ "openssl-probe", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "rustls-pki-types", "schannel", "security-framework", @@ -5083,11 +5083,11 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f48172685e6ff52a556baa527774f61fcaa884f59daf3375c62a3f1cd2549dab" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.21.7", + "base64 0.22.0", "rustls-pki-types", ] @@ -5120,9 +5120,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" [[package]] name = "ryu" @@ -5266,14 +5266,14 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "sequoia-openpgp" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebf154ce4af3d7983de8fded403f98ff9eb3ee38dffccea0472ac38aa4276df4" +checksum = "06f82708c8568218b8544b4abbba1f6483067dca0a946a54991c1d3f424dcade" dependencies = [ "aes", "aes-gcm", "anyhow", - "base64 0.21.7", + "base64 0.22.0", "block-padding", "blowfish 0.9.1", "buffered-reader", @@ -5566,7 +5566,7 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smtp" -version = "0.7.0" +version = "0.7.1" dependencies = [ "ahash 0.8.11", "bincode", @@ -5595,9 +5595,9 @@ dependencies = [ "rand", "rayon", "regex", - "reqwest 0.12.2", + "reqwest 0.12.3", "rustls 0.22.3", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "rustls-pki-types", "serde", "serde_json", @@ -5682,7 +5682,7 @@ dependencies = [ [[package]] name = "stalwart-cli" -version = "0.7.0" +version = "0.7.1" dependencies = [ "clap", "console", @@ -5698,7 +5698,7 @@ dependencies = [ "prettytable-rs", "pwhash", "rand", - "reqwest 0.12.2", + "reqwest 0.12.3", "rpassword", "serde", "serde_json", @@ -5713,7 +5713,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "store" -version = "0.7.0" +version = "0.7.1" dependencies = [ "ahash 0.8.11", "arc-swap", @@ -5951,9 +5951,9 @@ dependencies = [ "nlp", "num_cpus", "rayon", - "reqwest 0.12.2", + "reqwest 0.12.3", "rustls 0.22.3", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "rustls-pki-types", "serde", "serde_json", @@ -6001,9 +6001,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -6022,9 +6022,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -6220,7 +6220,7 @@ dependencies = [ "axum", "base64 0.21.7", "bytes", - "h2 0.3.25", + "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", "hyper 0.14.28", @@ -6556,7 +6556,7 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "utils" -version = "0.7.0" +version = "0.7.1" dependencies = [ "ahash 0.8.11", "base64 0.21.7", @@ -6573,12 +6573,12 @@ dependencies = [ "pem", "privdrop", "rand", - "rcgen 0.13.0", + "rcgen 0.13.1", "regex", - "reqwest 0.12.2", + "reqwest 0.12.3", "ring 0.17.8", "rustls 0.22.3", - "rustls-pemfile 2.1.1", + "rustls-pemfile 2.1.2", "rustls-pki-types", "serde", "serde_json", @@ -6823,9 +6823,9 @@ dependencies = [ [[package]] name = "widestring" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" [[package]] name = "winapi" @@ -7028,6 +7028,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "wyz" version = "0.5.1" diff --git a/Dockerfile b/Dockerfile index ad68bd17..a238e0dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,42 @@ -FROM debian:bullseye-slim +# Stalwart Dockerfile +# Credits: https://github.com/33KK -RUN apt-get update -y && apt-get install -yq ca-certificates curl +FROM --platform=$BUILDPLATFORM docker.io/lukemathwalker/cargo-chef:latest-rust-slim-bookworm AS chef +WORKDIR /build -COPY resources/docker/entrypoint.sh /usr/local/bin/entrypoint.sh -COPY resources/docker/download.sh /usr/local/bin/download.sh -RUN chmod a+rx /usr/local/bin/*.sh -RUN /usr/local/bin/download.sh -RUN rm /usr/local/bin/download.sh +FROM --platform=$BUILDPLATFORM chef AS planner +COPY . . +RUN cargo chef prepare --recipe-path /recipe.json -RUN useradd stalwart-mail -s /sbin/nologin -M -RUN mkdir -p /opt/stalwart-mail -RUN chown stalwart-mail:stalwart-mail /opt/stalwart-mail +FROM --platform=$BUILDPLATFORM chef AS builder +ARG TARGETPLATFORM +RUN case "${TARGETPLATFORM}" in \ + "linux/arm64") echo "aarch64-unknown-linux-gnu" > /target.txt && echo "-C linker=aarch64-linux-gnu-gcc" > /flags.txt ;; \ + "linux/amd64") echo "x86_64-unknown-linux-gnu" > /target.txt && echo "-C linker=x86_64-linux-gnu-gcc" > /flags.txt ;; \ + *) exit 1 ;; \ + esac +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && \ + apt-get install -yq build-essential libclang-16-dev \ + g++-aarch64-linux-gnu binutils-aarch64-linux-gnu \ + g++-x86-64-linux-gnu binutils-x86-64-linux-gnu +RUN rustup target add "$(cat /target.txt)" +COPY --from=planner /recipe.json /recipe.json +RUN RUSTFLAGS="$(cat /flags.txt)" cargo chef cook --target "$(cat /target.txt)" --release --recipe-path /recipe.json +COPY . . +RUN RUSTFLAGS="$(cat /flags.txt)" cargo build --target "$(cat /target.txt)" --release -p mail-server -p stalwart-cli +RUN mv "/build/target/$(cat /target.txt)/release" "/output" +FROM docker.io/debian:bookworm-slim +WORKDIR /opt/stalwart-mail +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && \ + apt-get install -yq ca-certificates +COPY --from=builder /output/stalwart-mail /usr/local/bin +COPY --from=builder /output/stalwart-cli /usr/local/bin +COPY ./resources/docker/entrypoint.sh /usr/local/bin/entrypoint.sh +RUN chmod -R 755 /usr/local/bin +CMD ["/usr/local/bin/stalwart-mail"] VOLUME [ "/opt/stalwart-mail" ] - EXPOSE 443 25 587 465 143 993 4190 8080 - ENTRYPOINT ["/bin/sh", "/usr/local/bin/entrypoint.sh"] diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 8983497d..385d2fa8 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Stalwart Labs Ltd. "] license = "AGPL-3.0-only" repository = "https://github.com/stalwartlabs/cli" homepage = "https://github.com/stalwartlabs/cli" -version = "0.7.0" +version = "0.7.1" edition = "2021" readme = "README.md" resolver = "2" diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index ffae666b..68d45b97 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "common" -version = "0.7.0" +version = "0.7.1" edition = "2021" resolver = "2" diff --git a/crates/directory/Cargo.toml b/crates/directory/Cargo.toml index a4ec8a68..d7a66ced 100644 --- a/crates/directory/Cargo.toml +++ b/crates/directory/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "directory" -version = "0.7.0" +version = "0.7.1" edition = "2021" resolver = "2" diff --git a/crates/imap/Cargo.toml b/crates/imap/Cargo.toml index 4bb4114b..ecde6d58 100644 --- a/crates/imap/Cargo.toml +++ b/crates/imap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "imap" -version = "0.7.0" +version = "0.7.1" edition = "2021" resolver = "2" diff --git a/crates/jmap/Cargo.toml b/crates/jmap/Cargo.toml index 4276f9ea..4221969e 100644 --- a/crates/jmap/Cargo.toml +++ b/crates/jmap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jmap" -version = "0.7.0" +version = "0.7.1" edition = "2021" resolver = "2" diff --git a/crates/main/Cargo.toml b/crates/main/Cargo.toml index cf33f12a..02762dea 100644 --- a/crates/main/Cargo.toml +++ b/crates/main/Cargo.toml @@ -7,7 +7,7 @@ homepage = "https://stalw.art" keywords = ["imap", "jmap", "smtp", "email", "mail", "server"] categories = ["email"] license = "AGPL-3.0-only" -version = "0.7.0" +version = "0.7.1" edition = "2021" resolver = "2" diff --git a/crates/managesieve/Cargo.toml b/crates/managesieve/Cargo.toml index 3319cdbe..0c72ae42 100644 --- a/crates/managesieve/Cargo.toml +++ b/crates/managesieve/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "managesieve" -version = "0.7.0" +version = "0.7.1" edition = "2021" resolver = "2" diff --git a/crates/nlp/Cargo.toml b/crates/nlp/Cargo.toml index 1152bcd4..d942da73 100644 --- a/crates/nlp/Cargo.toml +++ b/crates/nlp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nlp" -version = "0.7.0" +version = "0.7.1" edition = "2021" resolver = "2" diff --git a/crates/smtp/Cargo.toml b/crates/smtp/Cargo.toml index b03e0c3d..5f9ed6b8 100644 --- a/crates/smtp/Cargo.toml +++ b/crates/smtp/Cargo.toml @@ -7,7 +7,7 @@ homepage = "https://stalw.art/smtp" keywords = ["smtp", "email", "mail", "server"] categories = ["email"] license = "AGPL-3.0-only" -version = "0.7.0" +version = "0.7.1" edition = "2021" resolver = "2" diff --git a/crates/store/Cargo.toml b/crates/store/Cargo.toml index 2bb65a0c..5d156934 100644 --- a/crates/store/Cargo.toml +++ b/crates/store/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "store" -version = "0.7.0" +version = "0.7.1" edition = "2021" resolver = "2" diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index d63141d6..ce90aa4c 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "utils" -version = "0.7.0" +version = "0.7.1" edition = "2021" resolver = "2"