Skip to content

Commit dabfcf1

Browse files
committed
Initial commit
0 parents  commit dabfcf1

File tree

6 files changed

+409
-0
lines changed

6 files changed

+409
-0
lines changed

.github/workflows/build-image.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build image
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
build-and-push:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
attestations: write
18+
id-token: write
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Log in to ghcr.io
22+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
23+
with:
24+
registry: ${{ env.REGISTRY }}
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
- name: Build and push
30+
uses: docker/build-push-action@v6
31+
with:
32+
push: true
33+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
34+
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:cache
35+
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:cache,mode=max

Dockerfile

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
FROM ubuntu:24.04
2+
3+
ENV LANG="C.UTF-8"
4+
ENV HOME=/root
5+
6+
### BASE ###
7+
8+
RUN apt-get update \
9+
&& apt-get upgrade -y \
10+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
11+
binutils \
12+
sudo \
13+
build-essential \
14+
bzr \
15+
curl \
16+
default-libmysqlclient-dev \
17+
dnsutils \
18+
gettext \
19+
git \
20+
git-lfs \
21+
gnupg2 \
22+
inotify-tools \
23+
iputils-ping \
24+
jq \
25+
libbz2-dev \
26+
libc6 \
27+
libc6-dev \
28+
libcurl4-openssl-dev \
29+
libdb-dev \
30+
libedit2 \
31+
libffi-dev \
32+
libgcc-13-dev \
33+
libgcc1 \
34+
libgdbm-compat-dev \
35+
libgdbm-dev \
36+
libgdiplus \
37+
libgssapi-krb5-2 \
38+
liblzma-dev \
39+
libncurses-dev \
40+
libncursesw5-dev \
41+
libnss3-dev \
42+
libpq-dev \
43+
libpsl-dev \
44+
libpython3-dev \
45+
libreadline-dev \
46+
libsqlite3-dev \
47+
libssl-dev \
48+
libstdc++-13-dev \
49+
libunwind8 \
50+
libuuid1 \
51+
libxml2-dev \
52+
libz3-dev \
53+
make \
54+
moreutils \
55+
netcat-openbsd \
56+
openssh-client \
57+
pkg-config \
58+
protobuf-compiler \
59+
python3-pip \
60+
ripgrep \
61+
rsync \
62+
software-properties-common \
63+
sqlite3 \
64+
swig3.0 \
65+
tk-dev \
66+
tzdata \
67+
unixodbc-dev \
68+
unzip \
69+
uuid-dev \
70+
xz-utils \
71+
zip \
72+
zlib1g \
73+
zlib1g-dev \
74+
&& rm -rf /var/lib/apt/lists/*
75+
76+
### PYTHON ###
77+
78+
ARG PYENV_VERSION=v2.5.5
79+
ARG PYTHON_VERSION=3.11.12
80+
81+
# Install pyenv
82+
ENV PYENV_ROOT=/root/.pyenv
83+
ENV PATH=$PYENV_ROOT/bin:$PATH
84+
RUN git -c advice.detachedHead=0 clone --branch ${PYENV_VERSION} --depth 1 https://github.com/pyenv/pyenv.git "${PYENV_ROOT}" \
85+
&& echo 'export PYENV_ROOT="$HOME/.pyenv"' >> /etc/profile \
86+
&& echo 'export PATH="$$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"' >> /etc/profile \
87+
&& echo 'eval "$(pyenv init - bash)"' >> /etc/profile \
88+
&& cd ${PYENV_ROOT} && src/configure && make -C src \
89+
&& pyenv install 3.10 3.11.12 3.12 3.13 \
90+
&& pyenv global ${PYTHON_VERSION}
91+
# Install pipx for common global package managers (e.g. poetry)
92+
ENV PIPX_BIN_DIR=/root/.local/bin
93+
ENV PATH=$PIPX_BIN_DIR:$PATH
94+
RUN apt-get update && apt-get install -y pipx \
95+
&& pipx install poetry uv \
96+
# Preinstall common packages for each version
97+
&& for pyv in $(ls ${PYENV_ROOT}/versions/); do \
98+
${PYENV_ROOT}/versions/$pyv/bin/pip install --upgrade pip ruff black mypy pyright isort; \
99+
done
100+
101+
102+
### NODE ###
103+
104+
ARG NVM_VERSION=v0.40.2
105+
ARG NODE_VERSION=22
106+
107+
ENV NVM_DIR=/root/.nvm
108+
# Corepack tries to do too much - disable some of its features:
109+
# https://github.com/nodejs/corepack/blob/main/README.md
110+
ENV COREPACK_DEFAULT_TO_LATEST=0
111+
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
112+
ENV COREPACK_ENABLE_AUTO_PIN=0
113+
ENV COREPACK_ENABLE_STRICT=0
114+
RUN git -c advice.detachedHead=0 clone --branch ${NVM_VERSION} --depth 1 https://github.com/nvm-sh/nvm.git "${NVM_DIR}" \
115+
&& echo 'source $NVM_DIR/nvm.sh' >> /etc/profile \
116+
&& echo "prettier\neslint\ntypescript" > $NVM_DIR/default-packages \
117+
&& . $NVM_DIR/nvm.sh \
118+
&& nvm install 18 \
119+
&& nvm install 20 \
120+
&& nvm install 22 \
121+
&& nvm alias default $NODE_VERSION \
122+
&& corepack enable \
123+
&& corepack install -g yarn pnpm npm
124+
125+
### BUN ###
126+
127+
ARG BUN_VERSION=1.2.10
128+
129+
ENV BUN_INSTALL=/root/.bun
130+
ENV PATH="$BUN_INSTALL/bin:$PATH"
131+
132+
RUN mkdir -p "$BUN_INSTALL/bin" \
133+
&& curl -L --fail "https://github.com/oven-sh/bun/releases/download/bun-v${BUN_VERSION}/bun-linux-x64-baseline.zip" \
134+
-o /tmp/bun.zip \
135+
&& unzip -q /tmp/bun.zip -d "$BUN_INSTALL/bin" \
136+
&& mv "$BUN_INSTALL/bin/bun-linux-x64-baseline/bun" "$BUN_INSTALL/bin/bun" \
137+
&& chmod +x "$BUN_INSTALL/bin/bun" \
138+
&& rm -rf "$BUN_INSTALL/bin/bun-linux-x64-baseline" /tmp/bun.zip \
139+
&& echo 'export BUN_INSTALL=/root/.bun' >> /etc/profile \
140+
&& echo 'export PATH="$BUN_INSTALL/bin:$PATH"' >> /etc/profile
141+
142+
### JAVA ###
143+
144+
ARG JAVA_VERSION=21
145+
ARG GRADLE_VERSION=8.14
146+
ARG GRADLE_DOWNLOAD_SHA256=61ad310d3c7d3e5da131b76bbf22b5a4c0786e9d892dae8c1658d4b484de3caa
147+
148+
ENV GRADLE_HOME=/opt/gradle
149+
RUN apt-get update && apt-get install -y --no-install-recommends \
150+
openjdk-${JAVA_VERSION}-jdk \
151+
&& rm -rf /var/lib/apt/lists/* \
152+
&& curl -LO "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" \
153+
&& echo "${GRADLE_DOWNLOAD_SHA256} *gradle-${GRADLE_VERSION}-bin.zip" | sha256sum --check - \
154+
&& unzip gradle-${GRADLE_VERSION}-bin.zip \
155+
&& rm gradle-${GRADLE_VERSION}-bin.zip \
156+
&& mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \
157+
&& ln -s "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle
158+
159+
### SWIFT ###
160+
161+
ARG SWIFT_VERSION=6.1
162+
163+
# Install swift.
164+
RUN mkdir /tmp/swiftly \
165+
&& cd /tmp/swiftly \
166+
&& curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz \
167+
&& tar zxf swiftly-$(uname -m).tar.gz \
168+
&& ./swiftly init --quiet-shell-followup -y \
169+
&& echo '. ~/.local/share/swiftly/env.sh' >> /etc/profile \
170+
&& bash -lc "swiftly install --use ${SWIFT_VERSION}" \
171+
&& rm -rf /tmp/swiftly
172+
173+
### RUBY ###
174+
175+
RUN apt-get update && apt-get install -y --no-install-recommends \
176+
ruby-full
177+
178+
### RUST ###
179+
180+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
181+
sh -s -- -y --profile minimal \
182+
&& . "$HOME/.cargo/env" \
183+
&& rustup show
184+
185+
### GO ###
186+
187+
ARG GO_VERSION=1.23.8
188+
ARG GO_DOWNLOAD_SHA256=45b87381172a58d62c977f27c4683c8681ef36580abecd14fd124d24ca306d3f
189+
190+
# Go defaults GOROOT to /usr/local/go - we just need to update PATH
191+
ENV PATH=/usr/local/go/bin:$HOME/go/bin:$PATH
192+
RUN mkdir /tmp/go \
193+
&& cd /tmp/go \
194+
&& curl -O https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz \
195+
&& echo "${GO_DOWNLOAD_SHA256} *go${GO_VERSION}.linux-amd64.tar.gz" | sha256sum --check - \
196+
&& tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz \
197+
&& rm -rf /tmp/go
198+
199+
### BAZEL ###
200+
201+
RUN curl -L --fail https://github.com/bazelbuild/bazelisk/releases/download/v1.26.0/bazelisk-linux-amd64 -o /usr/local/bin/bazelisk \
202+
&& chmod +x /usr/local/bin/bazelisk \
203+
&& ln -s /usr/local/bin/bazelisk /usr/local/bin/bazel
204+
205+
### LLVM ###
206+
RUN apt-get update && apt-get install -y --no-install-recommends \
207+
git \
208+
cmake \
209+
ccache \
210+
python3 \
211+
ninja-build \
212+
nasm \
213+
yasm \
214+
gawk \
215+
lsb-release \
216+
wget \
217+
software-properties-common \
218+
gnupg \
219+
&& rm -rf /var/lib/apt/lists/* \
220+
&& bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
221+
222+
### SETUP SCRIPTS ###
223+
224+
COPY setup_universal.sh /opt/codex/setup_universal.sh
225+
RUN chmod +x /opt/codex/setup_universal.sh
226+
227+
COPY entrypoint.sh /opt/entrypoint.sh
228+
RUN chmod +x /opt/entrypoint.sh
229+
230+
ENTRYPOINT ["/opt/entrypoint.sh"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 OpenAI
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# codex-universal
2+
3+
`codex-universal` is a development implementation of the base Docker image available in [OpenAI Codex](https://github.com/openai/codex).
4+
5+
This repository is intended to help developers customizing environments in Codex by providing a similar image that can be pulled and run locally. This is not an identical environment but should help for debugging and development.
6+
7+
For docs on environment setup, see [OpenAI Codex](https://github.com/openai/codex).
8+
9+
## Usage
10+
11+
The below script shows how can you approximate the `setup` environment in Codex.
12+
13+
```
14+
docker pull ghcr.io/openai/codex-universal:latest
15+
```
16+
17+
```
18+
docker run --rm -it \
19+
# See below for environment variable options.
20+
-e CODEX_ENV_PYTHON_VERSION=3.12 \
21+
-e CODEX_ENV_NODE_VERSION=20 \
22+
-e CODEX_ENV_RUST_VERSION=1.86.0 \
23+
-e CODEX_ENV_GO_VERSION=1.23.8 \
24+
-e CODEX_ENV_SWIFT_VERSION=6.1 \
25+
# Mount the current directory similar to how it would get cloned in.
26+
-v $(pwd):/workspace/$(basename $(pwd)) -w /workspace/$(basename $(pwd)) \
27+
ghcr.io/openai/codex-universal:latest
28+
```
29+
30+
### Configuring language runtimes
31+
32+
The following env vars can be set to configure runtime installation. Note that a limited subset of versions are supported in the product (indicated in the table below)
33+
34+
| Environment variable | Description | Supported versions | Additional packages |
35+
| -------------------------- | -------------------------- | -------------------------------------- | -------------------------------------------------------------------- |
36+
| `CODEX_ENV_PYTHON_VERSION` | Python version to install | `3.10`, `3.11.12`, `3.12`, `3.13` | `pyenv`, `poetry`, `uv`, `ruff`, `black`, `mypy`, `pyright`, `isort` |
37+
| `CODEX_ENV_NODE_VERSION` | Node.js version to install | `18`, `20`, `22` | `corepack`, `yarn`, `pnpm`, `npm` |
38+
| `CODEX_ENV_RUST_VERSION` | Rust version to install | `1.83.0`, `1.84.1`, `1.85.1`, `1.86.0` | |
39+
| `CODEX_ENV_GO_VERSION` | Go version to install | `1.22.12`, `1.23.8`, `1.24.3` | |
40+
| `CODEX_ENV_SWIFT_VERSION` | Swift version to install | `5.10`, `6.1` | |
41+
42+
## What's included
43+
44+
In addition to the packages specified in the table above, the following packages are also installed:
45+
46+
- `ruby`: 3.2.3
47+
- `bun`: 1.2.10
48+
- `java`: 21
49+
- `bazelisk` / `bazel`
50+
51+
See [Dockerfile](Dockerfile) for the full details of installed packages.

entrypoint.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
echo "=================================="
4+
echo "Welcome to openai/codex-universal!"
5+
echo "=================================="
6+
7+
/opt/codex/setup_universal.sh
8+
9+
echo "Environment ready. Dropping you into a bash shell."
10+
exec bash --login "$@"

0 commit comments

Comments
 (0)