Skip to content

Commit

Permalink
Merge pull request #81 from kozakura913/main
Browse files Browse the repository at this point in the history
dummy.pngを実行ファイルに埋め込む
  • Loading branch information
kozakura913 authored Dec 29, 2024
2 parents 5bd1101 + 4afb7dc commit 004888d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ ARG GID="852"
RUN addgroup -g "${GID}" proxy && adduser -u "${UID}" -G proxy -D -h /media-proxy-rs -s /bin/sh proxy
WORKDIR /media-proxy-rs
USER proxy
COPY asset ./asset
COPY --from=1 /app/media-proxy-rs ./media-proxy-rs
COPY --from=1 /app/healthcheck ./healthcheck
RUN sh -c "./media-proxy-rs&" && ./healthcheck 12887 http://127.0.0.1:12766/test.webp
Expand Down
6 changes: 2 additions & 4 deletions examples/healthcheck.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{io::Read, net::SocketAddr, str::FromStr};
use std::{net::SocketAddr, str::FromStr};

use axum::{response::IntoResponse, Router};

Expand All @@ -12,9 +12,7 @@ fn main() {
rt.spawn(async move{
let app = Router::new();
let app=app.route("/dummy.png",axum::routing::get(||async{
let mut dummy_png=vec![];
std::fs::File::open("asset/dummy.png").expect("not found dummy.png").read_to_end(&mut dummy_png).expect("load error dummy.png");
(axum::http::StatusCode::OK,dummy_png).into_response()
(axum::http::StatusCode::OK,include_bytes!("../asset/dummy.png").to_vec()).into_response()
}));
axum::Server::bind(&http_addr).serve(app.into_make_service_with_connect_info::<SocketAddr>()).await.unwrap();
});
Expand Down
11 changes: 6 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::str;
use std::{io::{Read, Write}, net::SocketAddr, pin::Pin, str::FromStr, sync::Arc};
use std::{io::Write, net::SocketAddr, pin::Pin, str::FromStr, sync::Arc};

use axum::{body::StreamBody, http::HeaderMap, response::IntoResponse, Router};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -122,9 +122,7 @@ fn main() {
}
let config:ConfigFile=serde_json::from_reader(std::fs::File::open(&config_path).unwrap()).unwrap();

let mut dummy_png=vec![];
std::fs::File::open("asset/dummy.png").expect("not found dummy.png").read_to_end(&mut dummy_png).expect("load error dummy.png");
let dummy_png=Arc::new(dummy_png);
let dummy_png=Arc::new(include_bytes!("../asset/dummy.png").to_vec());
let config=Arc::new(config);
let rt=tokio::runtime::Builder::new_multi_thread().enable_all().build().unwrap();
let client=reqwest::ClientBuilder::new();
Expand All @@ -137,7 +135,10 @@ fn main() {
if config.load_system_fonts{
fontdb.load_system_fonts();
}
fontdb.load_fonts_dir("asset/font/");
if std::path::Path::new("asset/font/").exists(){
fontdb.load_fonts_dir("asset/font/");
}
fontdb.load_font_source(resvg::usvg::fontdb::Source::Binary(Arc::new(include_bytes!("../asset/font/Aileron-Light.otf"))));
let fontdb=Arc::new(fontdb);
let arg_tup=(client,config,dummy_png,fontdb);
rt.block_on(async{
Expand Down

0 comments on commit 004888d

Please sign in to comment.