Skip to content

Commit 0a5c067

Browse files
committed
build(docker): fix LazyLock compile
1 parent 5edef40 commit 0a5c067

9 files changed

+41
-40
lines changed

docker/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ COPY ../headless_browser_lib/ ./headless_browser_lib
1010
COPY ../benches/ ./benches
1111
COPY ../Cargo.* .
1212

13+
RUN rustup update stable
1314
RUN RUST_LOG=error cargo install --no-default-features --path headless_browser
1415

1516
FROM alpine:3.21

docker/Dockerfile.brave

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ COPY ../headless_browser_lib/ ./headless_browser_lib
1212
COPY ../benches/ ./benches
1313
COPY ../Cargo.* .
1414

15+
RUN rustup update stable
1516
RUN RUST_LOG=error cargo install --no-default-features --path headless_browser
1617

1718
FROM ubuntu:25.04

docker/Dockerfile.headless_shell

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ COPY ../headless_browser_lib/ ./headless_browser_lib
1111
COPY ../benches/ ./benches
1212
COPY ../Cargo.* .
1313

14+
RUN rustup update stable
1415
RUN RUST_LOG=error cargo install --no-default-features --path headless_browser
1516

1617
FROM alpine:3.21

docker/Dockerfile.headless_shell_playwright

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ COPY ../headless_browser_lib/ ./headless_browser_lib
1212
COPY ../benches/ ./benches
1313
COPY ../Cargo.* .
1414

15+
RUN rustup update stable
1516
RUN RUST_LOG=error cargo install --no-default-features --path headless_browser
1617

1718
FROM mcr.microsoft.com/playwright:v1.50.1-noble

docker/Dockerfile.lightpanda

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ COPY ../headless_browser_lib/ ./headless_browser_lib
8181
COPY ../benches/ ./benches
8282
COPY ../Cargo.* .
8383

84+
RUN rustup update stable
8485
RUN RUST_LOG=error cargo install --no-default-features --path headless_browser
8586

8687
FROM ubuntu:22.04

docker/Dockerfile.playwright

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ COPY ../headless_browser_lib/ ./headless_browser_lib
1010
COPY ../benches/ ./benches
1111
COPY ../Cargo.* .
1212

13+
RUN rustup update stable
1314
RUN RUST_LOG=error cargo install --no-default-features --path headless_browser
1415

1516
FROM alpine:3.21

docker/Dockerfile.xvfb

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ COPY ../headless_browser_lib/ ./headless_browser_lib
1010
COPY ../benches/ ./benches
1111
COPY ../Cargo.* .
1212

13+
RUN rustup update stable
1314
RUN RUST_LOG=error cargo install --no-default-features --path headless_browser
1415

1516
FROM alpine:3.21

headless_browser_lib/src/conf.rs

+28
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,34 @@ lazy_static::lazy_static! {
364364
pub(crate) static ref DEBUG_JSON: bool = std::env::var("DEBUG_JSON").unwrap_or_default() == "true";
365365
/// Test headless without args.
366366
pub(crate) static ref TEST_NO_ARGS: bool = std::env::var("TEST_NO_ARGS").unwrap_or_default() == "true";
367+
/// Entry port to the proxy.
368+
pub(crate) static ref ENTRY: &'static str = {
369+
if crate::TARGET_REPLACEMENT.0 == b":9223" {
370+
"0.0.0.0:9222"
371+
} else {
372+
"0.0.0.0:9223"
373+
}
374+
};
375+
/// Target chrome server.
376+
pub(crate) static ref TARGET: &'static str = {
377+
if crate::TARGET_REPLACEMENT.1 == b":9222" {
378+
"0.0.0.0:9223"
379+
} else {
380+
"0.0.0.0:9224"
381+
}
382+
};
383+
/// The buffer size.
384+
pub(crate) static ref BUFFER_SIZE: usize = {
385+
let buffer_size = std::env::var("BUFFER_SIZE")
386+
.ok()
387+
.and_then(|s| s.parse().ok())
388+
.unwrap_or(131072); // Default to 128kb
389+
buffer_size
390+
};
391+
/// 10 sec cache
392+
pub(crate) static ref TEN_SECONDS: std::time::Duration = {
393+
std::time::Duration::from_secs(10)
394+
};
367395
}
368396

369397
/// Get the default chrome bin location per OS.

headless_browser_lib/src/proxy.rs

+6-40
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,5 @@
1-
use std::time::Duration;
2-
3-
lazy_static::lazy_static! {
4-
/// Entry port to the proxy.
5-
static ref ENTRY: &'static str = {
6-
if crate::TARGET_REPLACEMENT.0 == b":9223" {
7-
"0.0.0.0:9222"
8-
} else {
9-
"0.0.0.0:9223"
10-
}
11-
};
12-
/// Target chrome server.
13-
static ref TARGET: &'static str = {
14-
if crate::TARGET_REPLACEMENT.1 == b":9222" {
15-
"0.0.0.0:9223"
16-
} else {
17-
"0.0.0.0:9224"
18-
}
19-
};
20-
/// The buffer size.
21-
static ref BUFFER_SIZE: usize = {
22-
let buffer_size = std::env::var("BUFFER_SIZE")
23-
.ok()
24-
.and_then(|s| s.parse().ok())
25-
.unwrap_or(131072); // Default to 128kb
26-
buffer_size
27-
};
28-
29-
/// 10 sec cache
30-
static ref TEN_SECONDS: Duration = {
31-
Duration::from_secs(10)
32-
};
33-
34-
}
35-
361
pub(crate) mod proxy {
2+
use crate::conf::{BUFFER_SIZE, ENTRY, TARGET, TEN_SECONDS};
373
use crate::{connect_with_retries, fork, shutdown_instances, CACHEABLE, LAST_CACHE};
384
use std::{io::ErrorKind, time::Instant};
395
use tokio::{
@@ -43,8 +9,8 @@ pub(crate) mod proxy {
439

4410
/// Run the proxy forwarder for chrome. This allows connecting to chrome outside of the network.
4511
pub async fn run_proxy() -> std::io::Result<()> {
46-
let listener = TcpListener::bind(*crate::proxy::ENTRY).await?;
47-
println!("Proxy Listening on {}", *crate::proxy::ENTRY);
12+
let listener = TcpListener::bind(*ENTRY).await?;
13+
println!("Proxy Listening on {}", *ENTRY);
4814
let base_time = Instant::now();
4915

5016
loop {
@@ -81,7 +47,7 @@ pub(crate) mod proxy {
8147
let total_elapsed =
8248
tokio::time::Duration::from_secs(elasped) + elapsed_since_base;
8349

84-
if total_elapsed >= *crate::proxy::TEN_SECONDS {
50+
if total_elapsed >= *TEN_SECONDS {
8551
CACHEABLE.store(true, std::sync::atomic::Ordering::Relaxed);
8652
}
8753
}
@@ -97,10 +63,10 @@ pub(crate) mod proxy {
9763

9864
/// Handle the proxy connection.
9965
async fn handle_connection(client_stream: &mut TcpStream) -> std::io::Result<()> {
100-
let server_stream: Option<TcpStream> = connect_with_retries(*crate::proxy::TARGET).await;
66+
let server_stream: Option<TcpStream> = connect_with_retries(*TARGET).await;
10167

10268
if let Some(mut server_stream) = server_stream {
103-
let buffer_size = *crate::proxy::BUFFER_SIZE;
69+
let buffer_size = *BUFFER_SIZE;
10470
let mut buf1 = vec![0u8; buffer_size];
10571
let mut buf2 = vec![0u8; buffer_size];
10672

0 commit comments

Comments
 (0)