feat(sdk_relay): Dockerfile runtime deps + RPC user/pass fallback via env
This commit is contained in:
parent
1f15562af3
commit
9cbd862269
@ -1,4 +1,4 @@
|
|||||||
FROM rust:1.75-alpine AS builder
|
FROM rust:1.83-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Dépendances de build
|
# Dépendances de build
|
||||||
@ -19,13 +19,16 @@ WORKDIR /home/bitcoin
|
|||||||
RUN adduser -D relay && \
|
RUN adduser -D relay && \
|
||||||
mkdir -p /home/bitcoin/.4nk && chown -R relay:relay /home/bitcoin
|
mkdir -p /home/bitcoin/.4nk && chown -R relay:relay /home/bitcoin
|
||||||
|
|
||||||
|
# Certificats et fuseaux (logs lisibles) minimal
|
||||||
|
RUN apk add --no-cache ca-certificates tzdata && update-ca-certificates
|
||||||
|
|
||||||
# Copier le binaire
|
# Copier le binaire
|
||||||
COPY --from=builder /app/target/release/sdk_relay /usr/local/bin/sdk_relay
|
COPY --from=builder /app/target/release/sdk_relay /usr/local/bin/sdk_relay
|
||||||
|
|
||||||
EXPOSE 8090 8091
|
EXPOSE 8090 8091
|
||||||
USER relay
|
USER relay
|
||||||
|
|
||||||
|
ENV RUST_LOG=info
|
||||||
|
|
||||||
# Le service lit la conf depuis "/home/bitcoin/.conf" (montée par docker-compose)
|
# Le service lit la conf depuis "/home/bitcoin/.conf" (montée par docker-compose)
|
||||||
CMD ["/usr/local/bin/sdk_relay"]
|
CMD ["/usr/local/bin/sdk_relay"]
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,20 +107,27 @@ fn rpc_connect(rpcwallet: Option<String>, network: Network, mut rpc_url: String,
|
|||||||
.url(&rpc_url)?
|
.url(&rpc_url)?
|
||||||
.timeout(Duration::from_secs(30));
|
.timeout(Duration::from_secs(30));
|
||||||
|
|
||||||
let cookie_path = match cookie_path {
|
// Prefer explicit user/pass via environment variables if provided
|
||||||
Some(path) => path,
|
let rpc_user_env = env::var("RELAY_RPC_USER").ok();
|
||||||
None => {
|
let rpc_pass_env = env::var("RELAY_RPC_PASSWORD").ok();
|
||||||
// Fallback to default path
|
|
||||||
let home = env::var("HOME")?;
|
|
||||||
let mut default_path = PathBuf::from_str(&home)?;
|
|
||||||
default_path.push(".bitcoin");
|
|
||||||
default_path.push(network.to_core_arg());
|
|
||||||
default_path.push(".cookie");
|
|
||||||
default_path
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let daemon_auth = SensitiveAuth(Auth::CookieFile(cookie_path));
|
let daemon_auth = if let (Some(u), Some(p)) = (rpc_user_env, rpc_pass_env) {
|
||||||
|
SensitiveAuth(Auth::UserPass(u, p))
|
||||||
|
} else {
|
||||||
|
let cookie_path = match cookie_path {
|
||||||
|
Some(path) => path,
|
||||||
|
None => {
|
||||||
|
// Fallback to default path
|
||||||
|
let home = env::var("HOME")?;
|
||||||
|
let mut default_path = PathBuf::from_str(&home)?;
|
||||||
|
default_path.push(".bitcoin");
|
||||||
|
default_path.push(network.to_core_arg());
|
||||||
|
default_path.push(".cookie");
|
||||||
|
default_path
|
||||||
|
}
|
||||||
|
};
|
||||||
|
SensitiveAuth(Auth::CookieFile(cookie_path))
|
||||||
|
};
|
||||||
let builder = match daemon_auth.get_auth() {
|
let builder = match daemon_auth.get_auth() {
|
||||||
Auth::None => builder,
|
Auth::None => builder,
|
||||||
Auth::UserPass(user, pass) => builder.auth(user, Some(pass)),
|
Auth::UserPass(user, pass) => builder.auth(user, Some(pass)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user