From d352e7537cdd9140be343868ed916a62315806f7 Mon Sep 17 00:00:00 2001 From: Maple Nebel Date: Wed, 5 Nov 2025 22:47:06 +0100 Subject: [PATCH] add dev container and default ip --- Dockerfile | 11 ++++++++--- devcontainer.json | 3 +++ rnex-core/src/executables/common.rs | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 devcontainer.json diff --git a/Dockerfile b/Dockerfile index c65fcff..30cd59f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,13 @@ -FROM rust:alpine AS builder +FROM rust:alpine AS dev-container + +RUN apk add --no-cache protobuf-dev git musl-dev lld openssl-dev openssl-libs-static + +FROM dev-container as builder WORKDIR /app COPY . . -RUN apk add --no-cache protobuf-dev git musl-dev lld openssl-dev openssl-libs-static - RUN git submodule update --init --recursive RUN OPENSSL_LIB_DIR=/usr/lib OPENSSL_INCLUDE_DIR=/usr/include/openssl OPENSSL_STATIC=1 RUSTFLAGS="-C relocation-model=static -C linker=ld.lld" cargo test --target x86_64-unknown-linux-musl @@ -32,3 +34,6 @@ ENTRYPOINT ["/backend_server_secure"] FROM scratch AS backend-secure COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/backend_server_secure /backend_server_secure ENTRYPOINT ["/backend_server_secure"] + +# make sure the final output container is the dev container so that we can use it from the devcontainer.json +FROM final as dev-container diff --git a/devcontainer.json b/devcontainer.json new file mode 100644 index 0000000..a1447f1 --- /dev/null +++ b/devcontainer.json @@ -0,0 +1,3 @@ +{ + "build": { "dockerfile": "Dockerfile" } +} diff --git a/rnex-core/src/executables/common.rs b/rnex-core/src/executables/common.rs index f12a84c..5697d7c 100644 --- a/rnex-core/src/executables/common.rs +++ b/rnex-core/src/executables/common.rs @@ -6,8 +6,8 @@ use crate::nex::account::Account; pub static OWN_IP_PRIVATE: Lazy = Lazy::new(|| { env::var("SERVER_IP") .ok() - .and_then(|s| s.parse().ok()) - .expect("SERVER_IP not specified") + .map(|s| s.parse().expect("invalid ip address")) + .unwrap_or(Ipv4Addr::UNSPECIFIED) }); pub static OWN_IP_PUBLIC: Lazy = Lazy::new(|| {