From 8866631a74bc0350844fbfcc1bf03726cceac26f Mon Sep 17 00:00:00 2001 From: "Morley, Jonathan" Date: Thu, 1 Jul 2021 15:01:42 -0400 Subject: [PATCH] put openssl back for windows --- .dockerignore | 12 ++++++++++++ Cargo.toml | 12 ++++++++---- Dockerfile | 29 +++++++++++++++++++++++++++++ src/config/credentials.rs | 2 +- src/main.rs | 3 --- src/{saml/mod.rs => saml.rs} | 0 6 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile rename src/{saml/mod.rs => saml.rs} (100%) diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..a2d8dfa9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.github/ +.ci/ +cross/ +target/ +.dockerignore +.editorconfig +.gitignore +.rustfmt +.tool-versions +Cross.toml +Dockerfile +README.md \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 59530afa..1288a222 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ description = "Generates temporary AWS credentials with Okta." edition = "2018" name = "oktaws" version = "0.13.1" + [dependencies] base64 = "0.13" confy = "*" @@ -28,10 +29,6 @@ serde_ini = "0.2" username = "0.2" walkdir = "2" -[dependencies.openssl] -features = ["vendored"] -version = "0.10" - [dependencies.reqwest] features = ["blocking", "cookies", "json"] version = "0.11" @@ -48,5 +45,12 @@ version = "0.3" features = ["serde"] version = "2.1" +[target] +[target."cfg(linux)"] +[target."cfg(linux)".dependencies] +[target."cfg(linux)".dependencies.openssl] +features = ["vendored"] +version = "0.10" + [dev-dependencies] tempfile = "3" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..4ab522fb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM clux/muslrust:1.53.0 as cargo-build + +RUN apt-get -y update && apt-get -y install libdbus-1-dev + +WORKDIR /usr/src/app +COPY Cargo.lock . +COPY Cargo.toml . +#RUN mkdir .cargo src +#RUN touch ./src/main.rs +#RUN --mount=type=cache,target=vendor \ +# cargo vendor > .cargo/config + +COPY ./src src +RUN --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=target/release/build \ + --mount=type=cache,target=target/release/deps \ + cargo build --release +#RUN cargo install --path . --verbose +#RUN --mount=type=cache,target=/root/.cargo/registry \ +# --mount=type=cache,target=target/release/build \ +# --mount=type=cache,target=target/release/deps \ +# cargo run --release -- --version +#RUN target/x86_64-unknown-linux-musl/release/oktaws --version + +FROM alpine +# Copy the compiled binary from the builder container +COPY --from=cargo-build /root/.cargo/bin/oktaws /oktaws +# Pass all arguments etc to binary +ENTRYPOINT [ "/oktaws" ] diff --git a/src/config/credentials.rs b/src/config/credentials.rs index 515a786b..921e89c1 100644 --- a/src/config/credentials.rs +++ b/src/config/credentials.rs @@ -52,5 +52,5 @@ pub fn save_credentials( let service = format!("oktaws::okta::{}", organization.name); Keyring::new(&service, username) .set_password(password) - .map_err(Into::into) + .map_err(|e| format_err!("{}", e)) } diff --git a/src/main.rs b/src/main.rs index 4a8cf2fd..4b6e20a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,3 @@ -#[cfg(windows)] -extern crate rpassword; - #[macro_use] extern crate failure; #[macro_use] diff --git a/src/saml/mod.rs b/src/saml.rs similarity index 100% rename from src/saml/mod.rs rename to src/saml.rs