diff --git a/Dockerfile b/Dockerfile index f53a955..be8a0ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,10 +11,14 @@ RUN cargo build --release FROM debian:$DEBIAN_RELEASE-slim -RUN apt-get update && apt-get install -y openssl && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y openssl ca-certificates && rm -rf /var/lib/apt/lists/* COPY --from=builder /app/target/release/atlas /usr/local/bin/ +RUN mkdir -p /opt/atlas/db && chown nobody:root /opt/atlas/db + USER nobody +ENV DB_PATH=/opt/atlas/db + CMD ["atlas"] diff --git a/src/download_utils.rs b/src/download_utils.rs index 9b906a5..6d66921 100644 --- a/src/download_utils.rs +++ b/src/download_utils.rs @@ -1,5 +1,6 @@ use core::fmt; use futures_util::StreamExt; +use std::env; use std::error::Error; use std::path::PathBuf; use tokio::fs::File; @@ -82,14 +83,15 @@ pub async fn download_with_basic_auth( pub async fn extract_db(path: &str, filename: &str) -> Result> { let full_path = PathBuf::from(path).join(filename); - let output = Command::new("tar") - .arg("xvfz") - .arg(&full_path) - .arg("-C") - .arg(path) - .arg("*.mmdb") - .output() - .await?; + let mut command = Command::new("tar"); + + command.arg("xvfz").arg(&full_path).arg("-C").arg(path); + + if env::consts::OS != "macos" { + command.arg("--wildcards"); + } + + let output = command.arg("*.mmdb").output().await?; if !output.status.success() { println!("{:?}", output); @@ -98,7 +100,12 @@ pub async fn extract_db(path: &str, filename: &str) -> Result output.stderr, + _ => output.stdout, + }; + + let extracted_filename = String::from_utf8(result)?.replace('\n', "")[2..].to_string(); Ok(extracted_filename) }