Skip to content

Commit 53eb54f

Browse files
authored
fix: Make lsp work in docker, plus some other install tweaks. (AztecProtocol#3661)
* LSP couldn't work in docker due to `ClientProcessMonitor` thing which needs to be able to see the pid of vscode, in order to exit when vscode is not there. Not quite sure why it's needed as vscode launches the process, so the process terminates on vscode exit anyway. * Mount HOME at HOME rather than /root. * Fix conditional. * Disable annoying CLI hints on windows docker. * Wrap nargo launcher in `tini` as it doesn't handle signals as expected. * Allow for debug builds of noir via script using env var.
1 parent b82b0c5 commit 53eb54f

File tree

6 files changed

+41
-24
lines changed

6 files changed

+41
-24
lines changed

aztec-up/bin/.aztec-run

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ VERSION=${VERSION:-"latest"}
1313
DOCKER_HOST_BINDS=""
1414

1515
# Volumes to pass to the container.
16-
DOCKER_VOLUME="-v $HOME:/root"
16+
DOCKER_VOLUME="-v $HOME:$HOME"
1717

1818
# Colors.
1919
y="\033[33m"
@@ -35,7 +35,7 @@ fi
3535

3636
# Set up host.docker.internal alias on Linux, just like it is on mac.
3737
UNAME=$(uname -s)
38-
if [ "$UNAME" == "Linux" ]; then
38+
if [[ -z "${SKIP_NET:-}" && "$UNAME" == "Linux" ]]; then
3939
if docker info 2>/dev/null | grep -q rootless; then
4040
# We're in rootless docker. Probe for the host ip and use that.
4141
ip=$(hostname -I | head | tr -d ' ')
@@ -58,7 +58,7 @@ done
5858
# If so, warn and exit.
5959
for i in "${!args[@]}"; do
6060
arg=${args[$i]}
61-
if [[ -f "$arg" || -d "$arg" && $(realpath $arg) != ${HOME}* ]]; then
61+
if [[ -f "$arg" || -d "$arg" ]] && [[ $(realpath $arg) != ${HOME}* ]]; then
6262
warn "Due to how we containerize our applications, paths outside of $HOME cannot be referenced."
6363
exit 1
6464
fi
@@ -77,7 +77,7 @@ DOCKER_VOLUME="$DOCKER_VOLUME -v cache:/cache"
7777
docker run \
7878
-ti \
7979
--rm \
80-
--workdir "${PWD/$HOME/\/root}" \
80+
--workdir "$PWD" \
8181
$DOCKER_HOST_BINDS \
8282
$DOCKER_ENV \
8383
$DOCKER_VOLUME \

aztec-up/bin/aztec-install

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function title() {
3333
if [ "$(uname -s)" == "Darwin" ]; then
3434
echo -e "${y}WARNING: For best performance we recommend adjusting your default docker settings:"
3535
echo -e " - Under general, enable VirtioFS."
36-
echo -e " - Under resources, set CPUs to ~80-100% your maximum."
36+
echo -e " - Under resources, set CPUs to ~80% your maximum."
3737
echo -e " - Under resources, set Memory to ~80% your maximum."
3838
echo -e "You may receive a warning about your home directory being mounted into a container."
3939
echo -e "This is requested so we can read and write project files, that is all."
@@ -100,6 +100,8 @@ function pull_container {
100100
fi
101101
}
102102

103+
export DOCKER_CLI_HINTS=false
104+
103105
if [ -z "${SKIP_PULL:-}" ]; then
104106
info "Pulling aztec version $VERSION..."
105107
pull_container aztec-sandbox
@@ -149,7 +151,7 @@ function update_path_env_var {
149151
echo
150152
if [[ $REPLY =~ ^[Yy]$ ]]; then
151153
# Add the target directory to the user's PATH in their profile.
152-
echo "export PATH=\$PATH:$TARGET_DIR" >> "$SHELL_PROFILE"
154+
echo "export PATH=\"\$PATH:$TARGET_DIR\"" >> "$SHELL_PROFILE"
153155
info "Done! Starting fresh shell..."
154156
$SHELL
155157
else

noir/Cargo.lock

+22-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

noir/Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ RUN ./scripts/bootstrap_native.sh
55

66
# When running the container, mount the users home directory to /root
77
FROM ubuntu:lunar
8+
# Install Tini as nargo doesn't handle signals properly.
9+
RUN apt-get update && apt-get install -y tini && rm -rf /var/lib/apt/lists/* && apt-get clean
810
COPY --from=0 /usr/src/noir/target/release/nargo /usr/src/noir/target/release/nargo
9-
WORKDIR /root
10-
ENTRYPOINT ["/usr/src/noir/target/release/nargo"]
11+
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/src/noir/target/release/nargo"]

noir/scripts/bootstrap_native.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ else
1313
fi
1414

1515
# Build native.
16-
cargo build --features="noirc_driver/aztec" --release
16+
if [ -n "${DEBUG:-}" ]; then
17+
cargo build --features="noirc_driver/aztec"
18+
else
19+
cargo build --features="noirc_driver/aztec" --release
20+
fi

noir/tooling/nargo_cli/src/cli/lsp_cmd.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use async_lsp::{
2-
client_monitor::ClientProcessMonitorLayer, concurrency::ConcurrencyLayer,
2+
concurrency::ConcurrencyLayer,
33
panic::CatchUnwindLayer, server::LifecycleLayer, tracing::TracingLayer,
44
};
55
use clap::Args;
@@ -39,10 +39,11 @@ pub(crate) fn run(
3939
.layer(LifecycleLayer::default())
4040
.layer(CatchUnwindLayer::default())
4141
.layer(ConcurrencyLayer::default())
42-
.layer(ClientProcessMonitorLayer::new(client))
4342
.service(router)
4443
});
4544

45+
eprintln!("LSP starting...");
46+
4647
// Prefer truly asynchronous piped stdin/stdout without blocking tasks.
4748
#[cfg(unix)]
4849
let (stdin, stdout) = (

0 commit comments

Comments
 (0)