Skip to content

Commit e103ab5

Browse files
fix arm64 build (#82)
1 parent b3b7c41 commit e103ab5

File tree

4 files changed

+45
-37
lines changed

4 files changed

+45
-37
lines changed

.github/workflows/build-image.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ env:
1818

1919
jobs:
2020
build-amd64:
21-
runs-on: ubuntu-latest
21+
runs-on: ubuntu-24.04
2222
outputs:
2323
digest: ${{ steps.build.outputs.digest }}
2424
steps:
@@ -50,7 +50,7 @@ jobs:
5050
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
5151
5252
build-arm64:
53-
runs-on: ubuntu-latest
53+
runs-on: ubuntu-24.04-arm
5454
outputs:
5555
digest: ${{ steps.build.outputs.digest }}
5656
steps:

Dockerfile

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM ubuntu:24.04
22

3+
ARG TARGETOS
4+
ARG TARGETARCH
5+
36
ENV LANG="C.UTF-8"
47
ENV HOME=/root
58
ENV DEBIAN_FRONTEND=noninteractive
@@ -54,8 +57,6 @@ RUN apt-get update \
5457
openssh-client=1:9.6p1-* \
5558
pkg-config=1.8.* \
5659
protobuf-compiler=3.21.* \
57-
python3=3.12.* \
58-
python3-pip=24.* \
5960
ripgrep=14.1.* \
6061
rsync=3.2.* \
6162
software-properties-common=0.99.* \
@@ -76,11 +77,9 @@ RUN apt-get update \
7677
### MISE ###
7778

7879
RUN install -dm 0755 /etc/apt/keyrings \
79-
&& curl -fsSL https://mise.jdx.dev/gpg-key.pub \
80-
| gpg --batch --yes --dearmor -o /etc/apt/keyrings/mise-archive-keyring.gpg \
80+
&& curl -fsSL https://mise.jdx.dev/gpg-key.pub | gpg --batch --yes --dearmor -o /etc/apt/keyrings/mise-archive-keyring.gpg \
8181
&& chmod 0644 /etc/apt/keyrings/mise-archive-keyring.gpg \
82-
&& echo "deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.gpg] https://mise.jdx.dev/deb stable main" \
83-
> /etc/apt/sources.list.d/mise.list \
82+
&& echo "deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.gpg] https://mise.jdx.dev/deb stable main" > /etc/apt/sources.list.d/mise.list \
8483
&& apt-get update \
8584
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends mise/stable \
8685
&& rm -rf /var/lib/apt/lists/* \
@@ -93,16 +92,16 @@ ENV PATH=$HOME/.local/share/mise/shims:$PATH
9392

9493
### LLVM ###
9594

96-
RUN install -dm 0755 /etc/apt/keyrings \
97-
&& curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key \
98-
| gpg --batch --yes --dearmor -o /etc/apt/keyrings/llvm.gpg \
99-
&& chmod 0644 /etc/apt/keyrings/llvm.gpg \
100-
&& . /etc/os-release \
101-
&& echo "deb [signed-by=/etc/apt/keyrings/llvm.gpg] https://apt.llvm.org/${VERSION_CODENAME}/ llvm-toolchain-${VERSION_CODENAME}-20 main" \
102-
> /etc/apt/sources.list.d/llvm.list \
103-
&& apt-get update \
104-
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends clang-20 lld-20 lldb-20 llvm-20 \
105-
&& rm -rf /var/lib/apt/lists/*
95+
RUN apt-get update && apt-get install -y --no-install-recommends \
96+
cmake=3.28.* \
97+
ccache=4.9.* \
98+
ninja-build=1.11.* \
99+
nasm=2.16.* \
100+
yasm=1.3.* \
101+
gawk=1:5.2.* \
102+
lsb-release=12.0-* \
103+
&& rm -rf /var/lib/apt/lists/* \
104+
&& bash -c "$(curl -fsSL https://apt.llvm.org/llvm.sh)"
106105

107106
### PYTHON ###
108107

@@ -121,7 +120,7 @@ RUN git -c advice.detachedHead=0 clone --branch "$PYENV_VERSION" --depth 1 https
121120
&& pyenv install $PYTHON_VERSIONS \
122121
&& pyenv global "$PYTHON_VERSION"
123122

124-
# Install pipx for common global package managers (e.g. poetry)
123+
# Install pipx for common global package managers (e.g. poetry)
125124
ENV PIPX_BIN_DIR=/root/.local/bin
126125
ENV PATH=$PIPX_BIN_DIR:$PATH
127126
RUN apt-get update && apt-get install -y --no-install-recommends pipx=1.4.* \
@@ -167,24 +166,29 @@ RUN mise use --global "bun@${BUN_VERSION}"
167166

168167
ARG GRADLE_VERSION=8.14
169168
ARG MAVEN_VERSION=3.9.10
170-
171169
# OpenJDK 11 is not available for arm64. Codex Web only uses amd64 which
172170
# does support 11.
173-
RUN if [ "$TARGETARCH" = "arm64" ]; then \
174-
JAVA_VERSIONS="21 17"; \
175-
else \
176-
JAVA_VERSIONS="21 17 11"; \
177-
fi; \
178-
for v in $JAVA_VERSIONS; do mise install "java@${v}"; done && \
179-
mise use --global "java@${JAVA_VERSIONS%% *}" && \
180-
mise use --global "gradle@${GRADLE_VERSION}" && \
181-
mise use --global "maven@${MAVEN_VERSION}"
171+
ARG AMD_JAVA_VERSIONS="21 17 11"
172+
ARG ARM_JAVA_VERSIONS="21 17"
173+
174+
RUN JAVA_VERSIONS="$( [ "$TARGETARCH" = "arm64" ] && echo "$ARM_JAVA_VERSIONS" || echo "$AMD_JAVA_VERSIONS" )" \
175+
&& for v in $JAVA_VERSIONS; do mise install "java@${v}"; done \
176+
&& mise use --global "java@${JAVA_VERSIONS%% *}" \
177+
&& mise use --global "gradle@${GRADLE_VERSION}" \
178+
&& mise use --global "maven@${MAVEN_VERSION}"
182179

183180
### SWIFT ###
184181

185182
ARG SWIFT_VERSIONS="6.1 5.10.1"
186-
RUN for v in $SWIFT_VERSIONS; do mise install "swift@${v}"; done \
187-
&& mise use --global "swift@${SWIFT_VERSIONS%% *}"
183+
# mise currently broken for swift on ARM
184+
RUN if [ "$TARGETARCH" = "amd64" ]; then \
185+
for v in $SWIFT_VERSIONS; do \
186+
mise install "swift@${v}"; \
187+
done && \
188+
mise use --global "swift@${SWIFT_VERSIONS%% *}"; \
189+
else \
190+
echo "Skipping Swift install on $TARGETARCH"; \
191+
fi
188192

189193
### RUST ###
190194

@@ -212,8 +216,6 @@ RUN pipx install cpplint==2.0.* clang-tidy==20.1.* clang-format==20.1.* cmakelan
212216

213217
### BAZEL ###
214218

215-
ARG TARGETOS
216-
ARG TARGETARCH
217219
ARG BAZELISK_VERSION=v1.26.0
218220

219221
RUN curl -L --fail https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-${TARGETOS}-${TARGETARCH} -o /usr/local/bin/bazelisk \
@@ -267,7 +269,7 @@ RUN chmod +x /opt/codex/setup_universal.sh
267269
### VERIFICATION SCRIPT ###
268270

269271
COPY verify.sh /opt/verify.sh
270-
RUN chmod +x /opt/verify.sh && bash -lc /opt/verify.sh
272+
RUN chmod +x /opt/verify.sh && bash -lc "TARGETARCH=$TARGETARCH /opt/verify.sh"
271273

272274
### ENTRYPOINT ###
273275

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ docker pull ghcr.io/openai/codex-universal:latest
1515
```
1616

1717
This repository builds the image for both linux/amd64 and linux/arm64. However we only run the linux/amd64 version.
18-
Your installed Docker may support linux/amd64 emulation by passing the `--platform linux/amd64` flag.
18+
Your installed Docker may support linux/amd64 emulation by passing the `--platform linux/amd64` flag.
19+
20+
The arm64 image differs from the amd64 image in 2 ways:
21+
- OpenJDK 10 is not available on amd64
22+
- The arm64 image skips installing swift because of a current bug with mise
1923

2024
The below script shows how can you approximate the `setup` environment in Codex:
2125

verify.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ javac -version
2727
gradle --version | head -n 3
2828
mvn --version | head -n 1
2929

30-
echo "- Swift:"
31-
swift --version
30+
if [ "$TARGETARCH" = "amd64" ]; then \
31+
echo "- Swift:"
32+
swift --version
33+
fi
3234

3335
echo "- Ruby:"
3436
ruby --version

0 commit comments

Comments
 (0)