diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000000..259e59ab31 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,29 @@ +FROM ubuntu:22.04 + +ARG DEBIAN_FRONTEND=noninteractive +# enable 'universe' because musl-tools & clang live there +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + software-properties-common && \ + add-apt-repository --yes universe + +# now install build deps +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + build-essential curl git ca-certificates \ + pkg-config clang musl-tools libssl-dev && \ + rm -rf /var/lib/apt/lists/* + +# non-root dev user +ARG USER=dev +ARG UID=1000 +RUN useradd -m -u $UID $USER +USER $USER + +# install Rust + musl target as dev user +RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal && \ + ~/.cargo/bin/rustup target add aarch64-unknown-linux-musl + +ENV PATH="/home/${USER}/.cargo/bin:${PATH}" + +WORKDIR /workspace diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 0000000000..0bd89a4e62 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,24 @@ +# Containerized Development + +## Docker + +To build the Docker image locally for x64 and then run it with the repo mounted: + +```shell +CODEX_DOCKER_IMAGE_NAME=codex-linux-dev +docker build --platform=linux/amd64 -t "$CODEX_DOCKER_IMAGE_NAME" ./.devcontainer +docker run --platform=linux/amd64 --rm -it -v "$PWD":/app -w /app "$CODEX_DOCKER_IMAGE_NAME" +``` + +For arm64, specify `linux/arm64` instead. + +Currently, the `Dockerfile` does not specify x64 vs. arm64, though you need to run `rustup target add x86_64-unknown-linux-musl` yourself to install the musl toolchain for x64. + +## VS Code + +If you open the workspace in a devcontainer in VS Code, in the terminal, you can build either flavor of the `arm64` build (GNU or musl): + +```shell +cargo build --target aarch64-unknown-linux-musl +cargo build --target aarch64-unknown-linux-gnu +``` diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..cabea96858 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,29 @@ +{ + "name": "Codex", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "platform": "linux/arm64" + }, + + /* Force VS Code to run the container as arm64 in + case your host is x86 (or vice-versa). */ + "runArgs": ["--platform=linux/arm64"], + + "containerEnv": { + "RUST_BACKTRACE": "1", + "CARGO_TARGET_DIR": "/workspace/target-aarch64" + }, + + "remoteUser": "dev", + "customizations": { + "vscode": { + "settings": { + "terminal.integrated.defaultProfile.linux": "bash" + }, + "extensions": [ + "rust-lang.rust-analyzer" + ], + } + } +} diff --git a/codex-rs/core/Cargo.toml b/codex-rs/core/Cargo.toml index 38f8446116..a3ea33654d 100644 --- a/codex-rs/core/Cargo.toml +++ b/codex-rs/core/Cargo.toml @@ -59,6 +59,10 @@ seccompiler = "0.5.0" [target.x86_64-unknown-linux-musl.dependencies] openssl-sys = { version = "*", features = ["vendored"] } +# Build OpenSSL from source for musl builds. +[target.aarch64-unknown-linux-musl.dependencies] +openssl-sys = { version = "*", features = ["vendored"] } + [dev-dependencies] assert_cmd = "2" maplit = "1.0.2"