Skip to content

Commit

Permalink
nargo needs git. Should set HOME in container.
Browse files Browse the repository at this point in the history
  • Loading branch information
charlielye committed Dec 14, 2023
1 parent ea7cd50 commit 1be03af
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
22 changes: 12 additions & 10 deletions aztec-up/bin/.aztec-run
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ if [[ $PWD != ${HOME}* ]]; then
fi

# Set up host.docker.internal alias on Linux, just like it is on mac.
UNAME=$(uname -s)
if [[ -z "${SKIP_NET:-}" && "$UNAME" == "Linux" ]]; then
if docker info 2>/dev/null | grep -q rootless; then
# We're in rootless docker. Probe for the host ip and use that.
ip=$(hostname -I | head | tr -d ' ')
warn "WARNING: Running within rootless docker. Using $ip as host ip. Ensure listening services are listening on this interface."
DOCKER_HOST_BINDS="$DOCKER_HOST_BINDS --add-host host.docker.internal:$ip"
else
DOCKER_HOST_BINDS="$DOCKER_HOST_BINDS --add-host host.docker.internal:host-gateway"
if [ -z "${SKIP_NET:-}" ]; then
UNAME=$(uname -s)
if [ "$UNAME" == "Linux" ]; then
if docker info 2>/dev/null | grep -q rootless; then
# We're in rootless docker. Probe for the host ip and use that.
ip=$(hostname -I | head | tr -d ' ')
warn "WARNING: Running within rootless docker. Using $ip as host ip. Ensure listening services are listening on this interface."
DOCKER_HOST_BINDS="$DOCKER_HOST_BINDS --add-host host.docker.internal:$ip"
else
DOCKER_HOST_BINDS="$DOCKER_HOST_BINDS --add-host host.docker.internal:host-gateway"
fi
fi
fi

Expand All @@ -64,7 +66,7 @@ for i in "${!args[@]}"; do
fi
done

DOCKER_ENV=""
DOCKER_ENV="-e HOME=$HOME"
for env in ${ENV_VARS_TO_INJECT:-}; do
# First substitute any reference to localhost with our host gateway.
env=${env//localhost/host.docker.internal}
Expand Down
8 changes: 7 additions & 1 deletion aztec-up/bin/aztec-nargo
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail

$(dirname $0)/.aztec-run aztecprotocol/noir $@
export SKIP_NET=1

if [ "${1:-}" == "lsp" ]; then
docker run -i -v $HOME:$HOME -e HOME=$HOME aztecprotocol/noir $@
else
$(dirname $0)/.aztec-run aztecprotocol/noir $@
fi
5 changes: 3 additions & 2 deletions noir/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ WORKDIR /usr/src/noir
COPY . .
RUN ./scripts/bootstrap_native.sh

# When running the container, mount the users home directory to /root
# When running the container, mount the users home directory to same location.
FROM ubuntu:lunar
# Install Tini as nargo doesn't handle signals properly.
RUN apt-get update && apt-get install -y tini && rm -rf /var/lib/apt/lists/* && apt-get clean
# Install git as nargo needs it to clone.
RUN apt-get update && apt-get install -y git tini && rm -rf /var/lib/apt/lists/* && apt-get clean
COPY --from=0 /usr/src/noir/target/release/nargo /usr/src/noir/target/release/nargo
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/src/noir/target/release/nargo"]

0 comments on commit 1be03af

Please sign in to comment.