Skip to content

Commit 5faa2a9

Browse files
committed
fix(redis): proper pathing for Rust binaries
1 parent 1dbf100 commit 5faa2a9

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

apps/redis/Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ LABEL org.opencontainers.image.licenses=MIT
77

88
ENV CARGO_HOME="/usr/local/cargo"
99
ENV RUSTUP_HOME="/usr/local/rustup"
10-
ENV AMP_ADDITIONAL_ENV_VARS="CARGO_HOME RUSTUP_HOME"
1110
ENV DEBIAN_FRONTEND="noninteractive"
1211

1312
# Install dependencies as per official Redis build instructions, and Rust for building modules
@@ -16,7 +15,12 @@ RUN set -eux; \
1615
apt-get install -o APT::Keep-Downloaded-Packages="false" -y --no-install-recommends \
1716
ca-certificates wget dpkg-dev gcc g++ libc6-dev libssl-dev make git cmake python3 \
1817
python3-pip python3-venv python3-dev unzip rsync clang automake autoconf libtool pkg-config; \
19-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain stable; \
18+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
19+
| sh -s -- -y --no-modify-path --profile minimal --default-toolchain stable; \
20+
/usr/local/cargo/bin/rustup default stable; \
21+
TOOLCHAIN="$(/usr/local/cargo/bin/rustup show active-toolchain | awk '{print $1}')"; \
22+
ln -s "/usr/local/rustup/toolchains/${TOOLCHAIN}/bin" /opt/rust-bin; \
23+
rm -f /usr/local/cargo/bin/cargo /usr/local/cargo/bin/rustc /usr/local/cargo/bin/rustdoc; \
2024
apt-get clean; \
2125
rm -rf /var/lib/apt/lists/*
2226

scripts/apps/redis/ampstart.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,23 @@ fi
9191
XDG_RUNTIME_DIR="/run/user/${AMPUSERID}"
9292
install -d -m 0700 -o amp -g amp "${XDG_RUNTIME_DIR}"
9393

94+
# Addition for Redis (for Rust)
95+
# PATH is also modified
96+
CARGO_HOME="/home/amp/.cargo"
97+
install -d -m 0755 -o amp -g amp "${CARGO_HOME}"
98+
9499
# Handoff
95100
echo "[Info] Starting AMP..."
96101
ARGS=$@
97-
# Use specific PATH for Redis to include Rust cargo bin
102+
# Use specific PATH for Redis to include Rust toolchain binaries, and add CARGO_HOME
98103
keep_env=(
99104
HOME=/home/amp
100105
USER=amp LOGNAME=amp SHELL=/bin/bash
101106
LANG="${LANG:-en_US.UTF-8}" LANGUAGE="${LANGUAGE:-en_US:en}" LC_ALL="${LC_ALL:-en_US.UTF-8}"
102-
PATH=/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
107+
PATH=/opt/rust-bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
103108
MAIL=/var/mail/amp
104109
XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR}"
110+
CARGO_HOME="${CARGO_HOME}"
105111
)
106112
# Always keep these AMP_ env vars if set
107113
for v in AMPHOSTPLATFORM AMP_CONTAINER AMP_CONTAINER_HOST_NETWORK AMPMEMORYLIMIT AMPSWAPLIMIT AMPCONTAINERCPUS; do

0 commit comments

Comments
 (0)