Merge 38f17182c9 into sapling-pr-archive-bolinfest

This commit is contained in:
Michael Bolin
2025-06-05 17:08:04 -07:00
committed by GitHub
4 changed files with 86 additions and 0 deletions

29
.devcontainer/Dockerfile Normal file
View File

@@ -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

24
.devcontainer/README.md Normal file
View File

@@ -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
```

View File

@@ -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"
],
}
}
}

View File

@@ -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"