From 10040d1f399f4e4ca35a4e680709305696b38bb3 Mon Sep 17 00:00:00 2001 From: Davide Polonio Date: Wed, 22 Sep 2021 16:08:30 +0200 Subject: [PATCH] Add first Docker image --- .dockerignore | 2 ++ Dockerfile | 17 +++++++++++++++++ src/main.rs | 10 +--------- 3 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..07827cc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +target/ +.idea/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8f5bd67 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM rust:1.55.0-alpine3.14 as builder + +ENV RUSTFLAGS="-C target-feature=+crt-static" +WORKDIR /build + +RUN apk add --no-cache musl-dev \ + openssl-dev \ + build-base + +COPY ./ /build +RUN cargo build --target x86_64-unknown-linux-musl --release # --verbose && ls -lah /build/target/release/build/ && ls -lah . + +FROM gcr.io/distroless/static + +COPY --from=builder /build/target/x86_64-unknown-linux-musl/release/songlify /usr/bin/songlify + +ENTRYPOINT /usr/bin/songlify \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 568c60f..e83b8b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use crate::SpotifyURL::Track; -use aspotify::{Client, ClientCredentials, Market}; +use aspotify::{Client, ClientCredentials}; use teloxide::prelude::*; enum SpotifyURL { @@ -17,14 +17,6 @@ fn get_spotify_entry(url: &str) -> Option { return None; } -fn is_spotify_url(url: &str) -> Option<&str> { - // https://open.spotify.com/track/0VffaI2jwQknRrxpECYHsF?si=1e16c64779744375 - if url.contains("https://open.spotify.com/") { - return Some(url); - } - return None; -} - struct TrackInfo { name: String, artist: Vec,