mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-25 22:01:19 +00:00
* Add feature to embed pictrs in lemmy binary (fixes #2627) * Add pictrs config * add protobuf Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
This commit is contained in:
parent
6eb5ed343c
commit
1eaf2c8a03
8 changed files with 838 additions and 25 deletions
|
@ -5,3 +5,4 @@ api_tests
|
||||||
ansible
|
ansible
|
||||||
tests
|
tests
|
||||||
*.sh
|
*.sh
|
||||||
|
pictrs
|
|
@ -29,6 +29,8 @@ steps:
|
||||||
environment:
|
environment:
|
||||||
CARGO_HOME: .cargo
|
CARGO_HOME: .cargo
|
||||||
commands:
|
commands:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get install -y --no-install-recommends protobuf-compiler libprotobuf-dev
|
||||||
- rustup component add clippy
|
- rustup component add clippy
|
||||||
- cargo clippy --workspace --tests --all-targets --all-features --
|
- cargo clippy --workspace --tests --all-targets --all-features --
|
||||||
-D warnings -D deprecated -D clippy::perf -D clippy::complexity
|
-D warnings -D deprecated -D clippy::perf -D clippy::complexity
|
||||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -18,3 +18,6 @@ query_testing/**/reports/*.json
|
||||||
|
|
||||||
# API tests
|
# API tests
|
||||||
api_tests/node_modules
|
api_tests/node_modules
|
||||||
|
|
||||||
|
# pictrs data
|
||||||
|
pictrs/
|
||||||
|
|
817
Cargo.lock
generated
817
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -30,8 +30,8 @@ strip = "symbols"
|
||||||
debug = 0
|
debug = 0
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
console = ["console-subscriber", "opentelemetry", "opentelemetry-otlp", "tracing-opentelemetry",
|
embed-pictrs = ["pict-rs"]
|
||||||
"reqwest-tracing/opentelemetry_0_16"]
|
console = ["console-subscriber", "opentelemetry", "opentelemetry-otlp", "tracing-opentelemetry", "reqwest-tracing/opentelemetry_0_16"]
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
|
@ -144,3 +144,5 @@ actix-rt = "2.6"
|
||||||
rand = { workspace = true }
|
rand = { workspace = true }
|
||||||
console-subscriber = { version = "0.1.8", optional = true }
|
console-subscriber = { version = "0.1.8", optional = true }
|
||||||
opentelemetry-otlp = { version = "0.10.0", optional = true }
|
opentelemetry-otlp = { version = "0.10.0", optional = true }
|
||||||
|
pict-rs = { version = "0.4.0-beta.9", optional = true }
|
||||||
|
tokio.workspace = true
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
# Pictrs image server configuration.
|
# Pictrs image server configuration.
|
||||||
pictrs: {
|
pictrs: {
|
||||||
# Address where pictrs is available (for image hosting)
|
# Address where pictrs is available (for image hosting)
|
||||||
url: "http://pictrs:8080/"
|
url: "http://localhost:8080/"
|
||||||
# Set a custom pictrs API key. ( Required for deleting images )
|
# Set a custom pictrs API key. ( Required for deleting images )
|
||||||
api_key: "string"
|
api_key: "string"
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,8 @@ pub struct Settings {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct PictrsConfig {
|
pub struct PictrsConfig {
|
||||||
/// Address where pictrs is available (for image hosting)
|
/// Address where pictrs is available (for image hosting)
|
||||||
#[default(Url::parse("http://pictrs:8080").expect("parse pictrs url"))]
|
#[default(Url::parse("http://localhost:8080").expect("parse pictrs url"))]
|
||||||
#[doku(example = "http://pictrs:8080")]
|
#[doku(example = "http://localhost:8080")]
|
||||||
pub url: Url,
|
pub url: Url,
|
||||||
|
|
||||||
/// Set a custom pictrs API key. ( Required for deleting images )
|
/// Set a custom pictrs API key. ( Required for deleting images )
|
||||||
|
|
28
src/main.rs
28
src/main.rs
|
@ -4,5 +4,31 @@ use lemmy_utils::{error::LemmyError, settings::SETTINGS};
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
pub async fn main() -> Result<(), LemmyError> {
|
pub async fn main() -> Result<(), LemmyError> {
|
||||||
init_logging(&SETTINGS.opentelemetry_url)?;
|
init_logging(&SETTINGS.opentelemetry_url)?;
|
||||||
start_lemmy_server().await
|
#[cfg(not(feature = "embed-pictrs"))]
|
||||||
|
start_lemmy_server().await?;
|
||||||
|
#[cfg(feature = "embed-pictrs")]
|
||||||
|
{
|
||||||
|
pict_rs::ConfigSource::memory(serde_json::json!({
|
||||||
|
"server": {
|
||||||
|
"address": "127.0.0.1:8080"
|
||||||
|
},
|
||||||
|
"old_db": {
|
||||||
|
"path": "./pictrs/old"
|
||||||
|
},
|
||||||
|
"repo": {
|
||||||
|
"type": "sled",
|
||||||
|
"path": "./pictrs/sled-repo"
|
||||||
|
},
|
||||||
|
"store": {
|
||||||
|
"type": "filesystem",
|
||||||
|
"path": "./pictrs/files"
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.init::<&str>(None)
|
||||||
|
.expect("initialize pictrs config");
|
||||||
|
let (lemmy, pictrs) = tokio::join!(start_lemmy_server(), pict_rs::run());
|
||||||
|
lemmy?;
|
||||||
|
pictrs.expect("run pictrs");
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue