From 840c2030755e74c802ab9499abcb09dbf745bf50 Mon Sep 17 00:00:00 2001 From: Fawad Shaikh Date: Mon, 30 Sep 2024 03:57:40 +0000 Subject: [PATCH 1/4] add missing details for new dev environment --- .../src/container/context.rs | 2 +- scripts/setup-containerd.sh | 51 +++++++++++++++++++ scripts/setup-linux.sh | 2 +- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 scripts/setup-containerd.sh diff --git a/crates/containerd-shim-wasm/src/container/context.rs b/crates/containerd-shim-wasm/src/container/context.rs index a809a1f9b..54eb18702 100644 --- a/crates/containerd-shim-wasm/src/container/context.rs +++ b/crates/containerd-shim-wasm/src/container/context.rs @@ -439,7 +439,7 @@ mod tests { }; let envs = ctx.envs(); - assert_eq!(envs.len(), 0); + assert_eq!(envs.len(), 2); Ok(()) } diff --git a/scripts/setup-containerd.sh b/scripts/setup-containerd.sh new file mode 100644 index 000000000..04492f088 --- /dev/null +++ b/scripts/setup-containerd.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# Exit immediately if a command exits with a non-zero status +set -e + +# Define variables +CONTAINERD_VERSION="1.7.22" +RUNC_VERSION="1.1.14" +CNI_PLUGINS_VERSION="1.5.1" + +# Change to arm64 if running on apple silicon +CHIPSET="arm64" + +# Define URLs +CONTAINERD_URL="https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VERSION}/containerd-${CONTAINERD_VERSION}-linux-${CHIPSET}.tar.gz" +RUNC_URL="https://github.com/opencontainers/runc/releases/download/v${RUNC_VERSION}/runc.${CHIPSET}" +CNI_PLUGINS_URL="https://github.com/containernetworking/plugins/releases/download/v${CNI_PLUGINS_VERSION}/cni-plugins-linux-${CHIPSET}-v${CNI_PLUGINS_VERSION}.tgz" +CONTAINERD_SERVICE_URL="https://raw.githubusercontent.com/containerd/containerd/main/containerd.service" + +# Install containerd +curl -LO $CONTAINERD_URL +sudo tar -C /usr/local -xzvf containerd-${CONTAINERD_VERSION}-linux-${CHIPSET}.tar.gz +rm -f containerd-${CONTAINERD_VERSION}-linux-${CHIPSET}.tar.gz + +# Install runc +curl -LO $RUNC_URL +sudo install -m 755 runc.${CHIPSET} /usr/local/sbin/runc +rm -f runc.${CHIPSET} + +# Install CNI plugins +curl -LO $CNI_PLUGINS_URL +sudo mkdir -p /opt/cni/bin +sudo tar -C /opt/cni/bin -xzvf cni-plugins-linux-${CHIPSET}-v${CNI_PLUGINS_VERSION}.tgz +rm -f cni-plugins-linux-${CHIPSET}-v${CNI_PLUGINS_VERSION}.tgz + +# Create containerd default configuration +sudo mkdir -p /etc/containerd +containerd config default | sudo tee /etc/containerd/config.toml + +# Modify the containerd config for systemd cgroup +sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml + +# Download and install the systemd service for containerd +sudo curl -L $CONTAINERD_SERVICE_URL -o /etc/systemd/system/containerd.service + +# Reload systemd daemon and start containerd +sudo systemctl daemon-reload +sudo systemctl start containerd +sudo systemctl enable containerd + +echo "containerd setup completed successfully!" diff --git a/scripts/setup-linux.sh b/scripts/setup-linux.sh index a3c58d1b9..9057f62f8 100755 --- a/scripts/setup-linux.sh +++ b/scripts/setup-linux.sh @@ -1,6 +1,6 @@ #!/bin/bash sudo apt -y update -sudo apt install -y pkg-config libsystemd-dev libdbus-glib-1-dev build-essential libelf-dev libseccomp-dev libclang-dev libzstd-dev protobuf-compiler +sudo apt install -y pkg-config libsystemd-dev libdbus-glib-1-dev build-essential libelf-dev libseccomp-dev libclang-dev libzstd-dev protobuf-compiler libssl-dev if [ ! -z "$CI" ] && ! mount | grep cgroup; then echo "cgroup is not mounted" 1>&2 From 273e5ae40ba7e37a4ca9a3124ec9fb85782ca95e Mon Sep 17 00:00:00 2001 From: Fawad Shaikh Date: Mon, 30 Sep 2024 04:03:22 +0000 Subject: [PATCH 2/4] update test name to be clear --- crates/containerd-shim-wasm/src/container/context.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/containerd-shim-wasm/src/container/context.rs b/crates/containerd-shim-wasm/src/container/context.rs index 54eb18702..51c017366 100644 --- a/crates/containerd-shim-wasm/src/container/context.rs +++ b/crates/containerd-shim-wasm/src/container/context.rs @@ -426,7 +426,7 @@ mod tests { } #[test] - fn test_envs_not_present() -> Result<()> { + fn test_envs_return_default_only() -> Result<()> { let spec = SpecBuilder::default() .root(RootBuilder::default().path("rootfs").build()?) .process(ProcessBuilder::default().cwd("/").build()?) From f45c5e18dab1e2270fd8a9bb1ae13e128f1b966e Mon Sep 17 00:00:00 2001 From: Fawad Shaikh Date: Tue, 1 Oct 2024 15:32:46 +0000 Subject: [PATCH 3/4] add libssl-dev to dockerfiles --- cross/Dockerfile.gnu | 2 +- cross/Dockerfile.musl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cross/Dockerfile.gnu b/cross/Dockerfile.gnu index e6d58067f..b7d83e816 100644 --- a/cross/Dockerfile.gnu +++ b/cross/Dockerfile.gnu @@ -5,4 +5,4 @@ FROM $CROSS_BASE_IMAGE ARG CROSS_DEB_ARCH RUN dpkg --add-architecture ${CROSS_DEB_ARCH} && \ apt-get -y update && \ - apt-get install -y pkg-config protobuf-compiler libseccomp-dev:${CROSS_DEB_ARCH} libzstd-dev:${CROSS_DEB_ARCH} + apt-get install -y pkg-config protobuf-compiler libseccomp-dev:${CROSS_DEB_ARCH} libzstd-dev:${CROSS_DEB_ARCH} libssl-dev diff --git a/cross/Dockerfile.musl b/cross/Dockerfile.musl index aaa73566f..76f5d0249 100644 --- a/cross/Dockerfile.musl +++ b/cross/Dockerfile.musl @@ -6,7 +6,7 @@ ENV MARCH=${CROSS_CMAKE_SYSTEM_PROCESSOR} RUN apk-init ${MARCH} ${CROSS_SYSROOT} # configure libsecccomp-rs to use static linking -RUN apk-${MARCH} add libseccomp-static libseccomp-dev +RUN apk-${MARCH} add libseccomp-static libseccomp-dev libssl-dev ENV LIBSECCOMP_LINK_TYPE="static" ENV LIBSECCOMP_LIB_PATH="${CROSS_SYSROOT}/lib" From cd6e93aa7f182116b30215a5d972149aacc83086 Mon Sep 17 00:00:00 2001 From: Fawad Shaikh Date: Tue, 1 Oct 2024 17:14:18 +0000 Subject: [PATCH 4/4] fix name to openssl --- cross/Dockerfile.musl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross/Dockerfile.musl b/cross/Dockerfile.musl index 76f5d0249..dd6e32544 100644 --- a/cross/Dockerfile.musl +++ b/cross/Dockerfile.musl @@ -6,7 +6,7 @@ ENV MARCH=${CROSS_CMAKE_SYSTEM_PROCESSOR} RUN apk-init ${MARCH} ${CROSS_SYSROOT} # configure libsecccomp-rs to use static linking -RUN apk-${MARCH} add libseccomp-static libseccomp-dev libssl-dev +RUN apk-${MARCH} add libseccomp-static libseccomp-dev openssl-dev ENV LIBSECCOMP_LINK_TYPE="static" ENV LIBSECCOMP_LIB_PATH="${CROSS_SYSROOT}/lib"