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
|
||||
|
||||
# Dépendances de build
|
||||
@ -19,13 +19,16 @@ WORKDIR /home/bitcoin
|
||||
RUN adduser -D relay && \
|
||||
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
|
||||
COPY --from=builder /app/target/release/sdk_relay /usr/local/bin/sdk_relay
|
||||
|
||||
EXPOSE 8090 8091
|
||||
USER relay
|
||||
|
||||
ENV RUST_LOG=info
|
||||
|
||||
# Le service lit la conf depuis "/home/bitcoin/.conf" (montée par docker-compose)
|
||||
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)?
|
||||
.timeout(Duration::from_secs(30));
|
||||
|
||||
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
|
||||
}
|
||||
};
|
||||
// Prefer explicit user/pass via environment variables if provided
|
||||
let rpc_user_env = env::var("RELAY_RPC_USER").ok();
|
||||
let rpc_pass_env = env::var("RELAY_RPC_PASSWORD").ok();
|
||||
|
||||
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() {
|
||||
Auth::None => builder,
|
||||
Auth::UserPass(user, pass) => builder.auth(user, Some(pass)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user