Skip to content

Commit b0a3124

Browse files
committed
add missing changes to dockerfile and login.rs
1 parent 760baaa commit b0a3124

2 files changed

Lines changed: 31 additions & 30 deletions

File tree

Dockerfile

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
1-
# Shared workspace builder stage - builds all dependencies once
2-
FROM rust:1-slim-trixie AS builder
3-
1+
# === DEPENDENCY PLANNING ===
2+
# Use pre-built cargo-chef image so we don't install it every build
3+
FROM lukemathwalker/cargo-chef:latest-rust-slim-trixie AS chef
44
WORKDIR /app
55

6-
# Install build dependencies
6+
# Analyze the workspace and produce a recipe file describing all dependencies
7+
FROM chef AS planner
8+
COPY . .
9+
RUN cargo chef prepare --recipe-path recipe.json
10+
11+
# === DEPENDENCY BUILDING ===
12+
# Build ONLY third-party dependencies from the recipe. This layer is cached
13+
# until any Cargo.toml changes — source code changes don't affect it.
14+
FROM chef AS cacher
715
RUN apt-get update && \
816
apt-get install -y --no-install-recommends pkg-config libssl-dev && \
917
rm -rf /var/lib/apt/lists/*
1018

11-
# Copy workspace Cargo.toml
12-
COPY Cargo.toml ./
13-
14-
# Copy all member Cargo.toml files for workspace resolution
15-
COPY packages/shared/Cargo.toml packages/shared/
16-
COPY packages/api/Cargo.toml packages/api/
17-
COPY packages/scanner/Cargo.toml packages/scanner/
18-
COPY migration/Cargo.toml migration/
19+
COPY --from=planner /app/recipe.json recipe.json
20+
RUN cargo chef cook --workspace --release --recipe-path recipe.json
1921

20-
# Create stub files for dependency resolution
21-
RUN mkdir -p packages/shared/src packages/api/src packages/scanner/src migration/src && \
22-
echo "pub fn main() {}" > packages/shared/src/lib.rs && \
23-
echo "fn main() {}" > packages/api/src/main.rs && \
24-
echo "fn main() {}" > packages/scanner/src/main.rs && \
25-
echo "pub fn main() {}" > migration/src/lib.rs
22+
# === APPLICATION BUILD ===
23+
# Copy compiled deps from cacher, then copy source and build. Only your
24+
# actual .rs files get recompiled when they change.
25+
FROM chef AS builder
26+
RUN apt-get update && \
27+
apt-get install -y --no-install-recommends pkg-config libssl-dev && \
28+
rm -rf /var/lib/apt/lists/*
2629

27-
# Fetch dependencies (cached unless Cargo.toml files change)
28-
RUN cargo fetch
30+
# Bring in pre-compiled dependency artifacts
31+
COPY --from=cacher /app/target target
32+
COPY --from=cacher /usr/local/cargo /usr/local/cargo
2933

30-
# Copy actual source code
31-
COPY packages/shared/src packages/shared/src
32-
COPY packages/api/src packages/api/src
33-
COPY packages/scanner/src packages/scanner/src
34-
COPY migration/src migration/src
34+
# Copy everything (source code + Cargo.toml files)
35+
COPY . .
3536

36-
# Build entire workspace - all shared dependencies compiled once
37+
# Build workspace — deps already compiled, only app code compiles
3738
RUN cargo build --workspace --release
3839

39-
# API service runtime
40+
# === API RUNTIME ===
4041
FROM debian:trixie-slim AS api-runtime
4142

4243
RUN apt-get update && \
@@ -58,7 +59,7 @@ ENV LISTEN_ADDR=0.0.0.0:3000
5859

5960
CMD ["nmcscan-api"]
6061

61-
# Scanner service runtime
62+
# === SCANNER RUNTIME ===
6263
FROM debian:trixie-slim AS scanner-runtime
6364

6465
RUN apt-get update && \

packages/shared/src/network/login.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
//! - 0x02 Login Success → offline mode enabled (cracked)
1414
//! - 0x03 Set Compression → read threshold, then expect Login Success
1515
16-
use once_cell::sync::Lazy;
1716
use regex::Regex;
1817
use std::io;
1918
use std::net::SocketAddr;
19+
use std::sync::LazyLock;
2020
use tokio::io::{AsyncReadExt, AsyncWriteExt};
2121
use tokio::net::TcpStream;
2222
use tokio::time::{Duration, timeout};
@@ -110,7 +110,7 @@ const VERSION_PROTOCOL_MAP: &[(i32, &[&str])] = &[
110110
];
111111

112112
/// Regex patterns for extracting version from disconnect messages.
113-
static OUTDATED_PATTERN: Lazy<Regex> = Lazy::new(|| {
113+
static OUTDATED_PATTERN: LazyLock<Regex> = LazyLock::new(|| {
114114
Regex::new(r"(?i)(?:outdated\s*server!?\s*(?:I'?m|I am)\s*still\s*on\s*|Incompatible\s*client!?\s*Please\s*use\s*|Please\s*use\s*Minecraft\s*)([0-9]+(?:\.[0-9]+)+(?:\.[0-9]+)*)").unwrap()
115115
});
116116

0 commit comments

Comments
 (0)