arlyon / async-stripe

Async (and blocking!) Rust bindings for the Stripe API
https://payments.rs
Apache License 2.0
464 stars 130 forks source link

Error building Rust application with async-stripe dependency and Docker #330

Closed DanStaj closed 1 year ago

DanStaj commented 1 year ago

Describe the bug

I am building a actix-web Rust application that uses the async-stripe crate dependency. When I run cargo build --release locally, the application compiles successfully and I am able to run the executable. However, when I try to build the application using Docker, I receive the following error:

#10 331.1 error: could not compile  async-stripe
#10 331.1
#10 331.1 Caused by:
#10 331.1   process didn't exit successfully: rustc --crate-name stripe --edition=2021 /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/async-stripe-0.15.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="async"' --cfg 'feature="async-std"' --cfg 'feature="billing"' --cfg 'feature="checkout"' --cfg 'feature="chrono"' --cfg 'feature="connect"' --cfg 'feature="events"' --cfg 'feature="futures-util"' --cfg 'feature="hex"' --cfg 'feature="hmac"' --cfg 'feature="runtime-async-std-surf"' --cfg 'feature="sha2"' --cfg 'feature="surf"' --cfg 'feature="webhook-events"' -C metadata=36c3bb1a9b76cf5f -C extra-filename=-36c3bb1a9b76cf5f --out-dir /app/target/release/deps -L dependency=/app/target/release/deps --extern async_std=/app/target/release/deps/libasync_std-d8b622e8c899ba59.rmeta --extern chrono=/app/target/release/deps/libchrono-2626b0faaded3c9a.rmeta --extern futures_util=/app/target/release/deps/libfutures_util-0596a52e378ec0aa.rmeta --extern hex=/app/target/release/deps/libhex-4ec505438719f7d6.rmeta --extern hmac=/app/target/release/deps/libhmac-eb5f6da96bed7783.rmeta --extern http_types=/app/target/release/deps/libhttp_types-fa198c5caa868d45.rmeta --extern serde=/app/target/release/deps/libserde-de195c50cd998f2c.rmeta --extern serde_json=/app/target/release/deps/libserde_json-a2083c3b3dd9a8cc.rmeta --extern serde_path_to_error=/app/target/release/deps/libserde_path_to_error-a8ba9b319dd9e1e9.rmeta --extern serde_qs=/app/target/release/deps/libserde_qs-18699877e5337cd1.rmeta --extern sha2=/app/target/release/deps/libsha2-448ca1e926301784.rmeta --extern smart_default=/app/target/release/deps/libsmart_default-a6327fcb7ea1a023.so --extern smol_str=/app/target/release/deps/libsmol_str-b71446cddab20e2b.rmeta --extern surf=/app/target/release/deps/libsurf-1718e97eca56d6e8.rmeta --extern thiserror=/app/target/release/deps/libthiserror-32902884dc906a4c.rmeta --cap-lints allow -L native=/usr/lib/x86_64-linux-gnu -L native=/app/target/release/build/libnghttp2-sys-ca1a5b431dfff1de/out/i/lib (signal: 9, SIGKILL: kill)

I have followed the steps in the async-stripe documentation for adding the dependency to my application and installing the necessary dependencies, but the issue only occurs when building the application using Docker.

To Reproduce

  1. Create a new actix-web Rust application and add the async-stripe dependency to the Cargo.toml file
  2. Create a Dockerfile for the application. Here is my dockerfile
FROM rust:1.65 as build
WORKDIR /usr/src/app
COPY . .

RUN cargo build --release

FROM gcr.io/distroless/cc-debian10

COPY --from=build /usr/src/staj/target/release/app /usr/local/bin/app

WORKDIR /usr/local/bin
CMD ["app"]
  1. Build the application using docker build .

Expected behavior

The application should build successfully

Code snippets

No response

OS

macOS

Rust version

1.67.0

Library version

async-stripe 0.15.1

API version

2020-08-27

Additional context

I've also tried using alpine in a multi-stage build. I've also tried using runtime-async-surf and runtime-tokio-hyper. Running a cargo build --release locally on my Mac works fine. Will try to run this cargo build on a linux system to verify if the problem is the OS rather than docker itself.

DanStaj commented 1 year ago

Just ran this docker build on a Debian machine and was able to successfully create the image.