Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9372b8ea07 | |||
| 02cc833cd9 |
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
ROOT_DIRECTORY=/usr/local/bin
|
ROOT_DIRECTORY=/usr/local/bin
|
||||||
ICARUS_BASE_API_URL=http://api:3000
|
ICARUS_BASE_API_URL=http://api:8000
|
||||||
ICARUS_AUTH_BASE_API_URL=http://auth_api:3000
|
ICARUS_AUTH_BASE_API_URL=http://auth_api:8001
|
||||||
SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH
|
SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
ROOT_DIRECTORY=/tmp
|
||||||
|
ICARUS_BASE_API_URL=http://localhost:8000
|
||||||
|
ICARUS_AUTH_BASE_API_URL=http://localhost:8001
|
||||||
|
SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH
|
||||||
@@ -10,14 +10,14 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Important for git describe --tags
|
fetch-depth: 0 # Important for git describe --tags
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.94
|
toolchain: 1.96.1
|
||||||
components: cargo
|
components: cargo
|
||||||
|
|
||||||
- name: Extract Version from Cargo.toml
|
- name: Extract Version from Cargo.toml
|
||||||
|
|||||||
@@ -1,24 +1,27 @@
|
|||||||
name: Rust Build
|
name: songparser
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- devel
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- devel
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
name: Check
|
name: Check
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.94
|
toolchain: 1.96.1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||||
@@ -28,33 +31,16 @@ jobs:
|
|||||||
ssh-add -v ~/.ssh/gitlab_deploy_key
|
ssh-add -v ~/.ssh/gitlab_deploy_key
|
||||||
cargo check
|
cargo check
|
||||||
|
|
||||||
test:
|
|
||||||
name: Test Suite
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
needs: setup_ssh
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: 1.94
|
|
||||||
- run: |
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
|
||||||
chmod 600 ~/.ssh/gitlab_deploy_key
|
|
||||||
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
|
|
||||||
eval $(ssh-agent -s)
|
|
||||||
ssh-add -v ~/.ssh/gitlab_deploy_key
|
|
||||||
cargo test
|
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
name: Rustfmt
|
name: Rustfmt
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs: setup_ssh
|
needs: setup_ssh
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.94
|
toolchain: 1.96.1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: rustup component add rustfmt
|
- run: rustup component add rustfmt
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
@@ -70,10 +56,11 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs: setup_ssh
|
needs: setup_ssh
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.94
|
toolchain: 1.96.1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: rustup component add clippy
|
- run: rustup component add clippy
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
@@ -89,10 +76,11 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs: setup_ssh
|
needs: setup_ssh
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.94
|
toolchain: 1.96.1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||||
|
|||||||
Generated
+496
-513
File diff suppressed because it is too large
Load Diff
+11
-11
@@ -1,18 +1,18 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "songparser"
|
name = "songparser"
|
||||||
version = "0.5.0"
|
version = "0.6.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.94"
|
rust-version = "1.95"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "1.51", features = ["full"] }
|
tokio = { version = "1.52.3", features = ["full"] }
|
||||||
futures = { version = "0.3.32" }
|
futures = { version = "0.3.32" }
|
||||||
reqwest = { version = "0.12.28", features = ["json", "stream", "multipart"] }
|
reqwest = { version = "0.13.4", features = ["json", "stream", "multipart"] }
|
||||||
|
openssl = { version = "0.10.81", features = ["vendored"] }
|
||||||
serde = { version = "1.0.228", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.149" }
|
serde_json = { version = "1.0.150" }
|
||||||
time = { version = "0.3.47", features = ["macros", "serde"] }
|
time = { version = "0.3.53", features = ["macros", "serde"] }
|
||||||
uuid = { version = "1.23", features = ["v4", "serde"] }
|
uuid = { version = "1.23.4", features = ["v4", "serde"] }
|
||||||
rand = { version = "0.10.0" }
|
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.6.1" }
|
||||||
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.5.0" }
|
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.11.3" }
|
||||||
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.10.0" }
|
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.8.0" }
|
||||||
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.6.0" }
|
|
||||||
|
|||||||
+3
-29
@@ -1,63 +1,37 @@
|
|||||||
# Stage 1: Build the application
|
FROM rust:1.96.1 as builder
|
||||||
# Use a specific Rust version for reproducibility. Choose one that matches your development environment.
|
|
||||||
# Using slim variant for smaller base image
|
|
||||||
FROM rust:1.94 as builder
|
|
||||||
|
|
||||||
# Set the working directory inside the container
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
# Install build dependencies if needed (e.g., git for cloning)
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
pkg-config libssl3 \
|
pkg-config libssl3 \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
openssh-client git \
|
openssh-client git \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# << --- ADD HOST KEY HERE --- >>
|
|
||||||
# Replace 'yourgithost.com' with the actual hostname (e.g., github.com)
|
|
||||||
RUN mkdir -p -m 0700 ~/.ssh && \
|
RUN mkdir -p -m 0700 ~/.ssh && \
|
||||||
ssh-keyscan git.kundeng.us >> ~/.ssh/known_hosts
|
ssh-keyscan git.kundeng.us >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
# Copy Cargo manifests
|
|
||||||
COPY Cargo.toml Cargo.lock ./
|
COPY Cargo.toml Cargo.lock ./
|
||||||
|
|
||||||
# Build *only* dependencies to leverage Docker cache
|
|
||||||
# This dummy build caches dependencies as a separate layer
|
|
||||||
RUN --mount=type=ssh mkdir src && \
|
RUN --mount=type=ssh mkdir src && \
|
||||||
echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs && \
|
echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs && \
|
||||||
cargo build --release --quiet && \
|
cargo build --release --quiet && \
|
||||||
rm -rf src target/release/deps/songparser* # Clean up dummy build artifacts (replace songparser)
|
rm -rf src target/release/deps/songparser*
|
||||||
|
|
||||||
# Copy the actual source code
|
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
# If you have other directories like `templates` or `static`, copy them too
|
|
||||||
COPY .env ./.env
|
COPY .env ./.env
|
||||||
|
|
||||||
# << --- SSH MOUNT ADDED HERE --- >>
|
|
||||||
# Build *only* dependencies to leverage Docker cache
|
|
||||||
# This dummy build caches dependencies as a separate layer
|
|
||||||
# Mount the SSH agent socket for this command
|
|
||||||
RUN --mount=type=ssh \
|
RUN --mount=type=ssh \
|
||||||
cargo build --release --quiet
|
cargo build --release --quiet
|
||||||
|
|
||||||
# Stage 2: Create the final, smaller runtime image
|
FROM debian:trixie-slim
|
||||||
# Use a minimal base image like debian-slim or even distroless for security/size
|
|
||||||
FROM ubuntu:24.04
|
|
||||||
|
|
||||||
# Install runtime dependencies if needed (e.g., SSL certificates)
|
|
||||||
RUN apt-get update && apt-get install -y ca-certificates libssl-dev libssl3 && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y ca-certificates libssl-dev libssl3 && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Set the working directory
|
|
||||||
WORKDIR /usr/local/bin
|
WORKDIR /usr/local/bin
|
||||||
|
|
||||||
# Copy the compiled binary from the builder stage
|
|
||||||
# Replace 'songparser' with the actual name of your binary (usually the crate name)
|
|
||||||
COPY --from=builder /usr/src/app/target/release/songparser .
|
COPY --from=builder /usr/src/app/target/release/songparser .
|
||||||
|
|
||||||
# Copy other necessary files like .env (if used for runtime config) or static assets
|
|
||||||
# It's generally better to configure via environment variables in Docker though
|
|
||||||
COPY --from=builder /usr/src/app/.env .
|
COPY --from=builder /usr/src/app/.env .
|
||||||
|
|
||||||
# Set the command to run your application
|
|
||||||
# Ensure this matches the binary name copied above
|
|
||||||
CMD ["./songparser"]
|
CMD ["./songparser"]
|
||||||
|
|||||||
+4
-5
@@ -1,12 +1,11 @@
|
|||||||
version: '3.8' # Use a recent version
|
version: '3.8' # Use a recent version
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# Your Rust Application Service
|
|
||||||
songparser:
|
songparser:
|
||||||
build: # Tells docker-compose to build the Dockerfile in the current directory
|
build:
|
||||||
context: .
|
context: .
|
||||||
ssh: ["default"] # Uses host's SSH agent
|
ssh: ["default"]
|
||||||
container_name: songparser # Optional: Give the container a specific name
|
container_name: songparser
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
restart: unless-stopped # Optional: Restart policy
|
restart: unless-stopped
|
||||||
|
|||||||
+4
-14
@@ -75,14 +75,9 @@ pub mod get_metadata_queue {
|
|||||||
) -> Result<reqwest::Response, reqwest::Error> {
|
) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let endpoint = String::from("api/v2/song/metadata/queue");
|
let endpoint = String::from("api/v2/song/metadata/queue");
|
||||||
let api_url = format!("{}/{endpoint}", app.uri);
|
let api_url = format!("{}/{endpoint}?song_queue_id={song_queue_id}", app.uri);
|
||||||
let (key, header) = super::auth_header(app).await;
|
let (key, header) = super::auth_header(app).await;
|
||||||
client
|
client.get(api_url).header(key, header).send().await
|
||||||
.get(api_url)
|
|
||||||
.query(&[("song_queue_id", song_queue_id)])
|
|
||||||
.header(key, header)
|
|
||||||
.send()
|
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod response {
|
pub mod response {
|
||||||
@@ -128,14 +123,9 @@ pub mod get_coverart_queue {
|
|||||||
) -> Result<reqwest::Response, reqwest::Error> {
|
) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let endpoint = String::from("api/v2/coverart/queue");
|
let endpoint = String::from("api/v2/coverart/queue");
|
||||||
let api_url = format!("{}/{endpoint}", app.uri);
|
let api_url = format!("{}/{endpoint}?song_queue_id={song_queue_id}", app.uri);
|
||||||
let (key, header) = super::auth_header(app).await;
|
let (key, header) = super::auth_header(app).await;
|
||||||
client
|
client.get(api_url).header(key, header).send().await
|
||||||
.get(api_url)
|
|
||||||
.query(&[("song_queue_id", song_queue_id)])
|
|
||||||
.header(key, header)
|
|
||||||
.send()
|
|
||||||
.await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_data(
|
pub async fn get_data(
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ pub async fn get_token(
|
|||||||
let api_url = format!("{}/{endpoint}", app.auth_uri);
|
let api_url = format!("{}/{endpoint}", app.auth_uri);
|
||||||
|
|
||||||
let payload = serde_json::json!({
|
let payload = serde_json::json!({
|
||||||
"passphrase": icarus_envy::environment::get_service_passphrase().await.value,
|
"passphrase": icarus_envy::environment::get_service_passphrase().value,
|
||||||
});
|
});
|
||||||
|
|
||||||
match client.post(api_url).json(&payload).send().await {
|
match client.post(api_url).json(&payload).send().await {
|
||||||
|
|||||||
+3
-7
@@ -15,13 +15,9 @@ impl App {
|
|||||||
|
|
||||||
pub async fn initialize_app_config() -> App {
|
pub async fn initialize_app_config() -> App {
|
||||||
App {
|
App {
|
||||||
uri: icarus_envy::environment::get_icarus_base_api_url()
|
uri: icarus_envy::environment::get_icarus_base_api_url().value,
|
||||||
.await
|
auth_uri: icarus_envy::environment::get_icarus_auth_base_api_url().value,
|
||||||
.value,
|
root_directory: icarus_envy::environment::get_root_directory().value,
|
||||||
auth_uri: icarus_envy::environment::get_icarus_auth_base_api_url()
|
|
||||||
.await
|
|
||||||
.value,
|
|
||||||
root_directory: icarus_envy::environment::get_root_directory().await.value,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -105,7 +105,7 @@ pub async fn prep_song(
|
|||||||
match crate::api::parsing::parse_response_into_bytes(response).await {
|
match crate::api::parsing::parse_response_into_bytes(response).await {
|
||||||
Ok(song_bytes) => {
|
Ok(song_bytes) => {
|
||||||
let song = icarus_models::song::Song {
|
let song = icarus_models::song::Song {
|
||||||
directory: icarus_envy::environment::get_root_directory().await.value,
|
directory: icarus_envy::environment::get_root_directory().value,
|
||||||
filename: icarus_models::song::generate_filename(
|
filename: icarus_models::song::generate_filename(
|
||||||
icarus_models::types::MusicType::FlacExtension,
|
icarus_models::types::MusicType::FlacExtension,
|
||||||
true,
|
true,
|
||||||
@@ -233,7 +233,7 @@ async fn init_queued_coverart(
|
|||||||
icarus_models::types::CoverArtType::None
|
icarus_models::types::CoverArtType::None
|
||||||
};
|
};
|
||||||
let coverart = icarus_models::coverart::CoverArt {
|
let coverart = icarus_models::coverart::CoverArt {
|
||||||
directory: icarus_envy::environment::get_root_directory().await.value,
|
directory: icarus_envy::environment::get_root_directory().value,
|
||||||
filename: match icarus_models::coverart::generate_filename(covart_type, true) {
|
filename: match icarus_models::coverart::generate_filename(covart_type, true) {
|
||||||
Ok(filename) => filename,
|
Ok(filename) => filename,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user