valeriansaliou / sonic

🦔 Fast, lightweight & schema-less search backend. An alternative to Elasticsearch that runs on a few MBs of RAM.
https://crates.io/crates/sonic-server
Mozilla Public License 2.0
20.05k stars 577 forks source link

MUSL build framework for Intel + ARM targets #218

Open valeriansaliou opened 4 years ago

valeriansaliou commented 4 years ago

Currently not possible due to __dso_handle linking failures due to GCC.

valeriansaliou commented 4 years ago

Falling back on a cross-compiled binary that depends on GNU libraries instead (GLIBC).

valeriansaliou commented 4 years ago

Ref: https://github.com/rust-rocksdb/rust-rocksdb/issues/440

valeriansaliou commented 4 years ago

Quoting from: https://github.com/rust-rocksdb/rust-rocksdb/issues/440#issuecomment-704959749 Will try this soon!

FROM alpine:edge as build

WORKDIR /work
RUN    apk --no-cache add rust cargo g++ openssl openssl-dev clang jq ca-certificates bash linux-headers

ENV OPENSSL_STATIC=yes \
    PKG_CONFIG_ALLOW_CROSS=true \
    PKG_CONFIG_ALL_STATIC=true \
    RUSTFLAGS="-C target-feature=+crt-static"

COPY . .

RUN --mount=type=ssh \
    --mount=type=cache,target=/root/.cargo/registry \
    --mount=type=cache,target=/root/.cargo/git \
    --mount=type=cache,target=/work/target \
    cargo install --release --target x86_64-alpine-linux-musl

FROM scratch
WORKDIR /work
ENV PATH=/work:${PATH}
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /root/.cargo/bin/exe /work

ENTRYPOINT ["exe"]