-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
86 lines (73 loc) · 3.34 KB
/
Copy pathDockerfile
File metadata and controls
86 lines (73 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# syntax=docker/dockerfile:1.7
ARG RUST_VERSION=1.95.0
FROM rust:${RUST_VERSION}-bookworm AS builder
ARG DEBIAN_FRONTEND=noninteractive
ARG BUILD_PROFILE=release
ARG CARGO_PROFILE_RELEASE_LTO=thin
ARG CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
clang \
cmake \
git \
libsqlite3-dev \
libssl-dev \
pkg-config \
protobuf-compiler \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/src/codex-rs/target \
cd codex-rs \
&& case "$BUILD_PROFILE" in \
release) \
CARGO_PROFILE_RELEASE_LTO="$CARGO_PROFILE_RELEASE_LTO" CARGO_PROFILE_RELEASE_CODEGEN_UNITS="$CARGO_PROFILE_RELEASE_CODEGEN_UNITS" cargo build --locked --release -p codex-cli --bin codex -p codex-enterprise-server --bin codex-enterprise-server -p codex-app-server --bin codex-app-server \
&& install -m 0755 target/release/codex /usr/local/bin/codex \
&& install -m 0755 target/release/codex-enterprise-server /usr/local/bin/codex-enterprise-server \
&& install -m 0755 target/release/codex-app-server /usr/local/bin/codex-app-server ;; \
dev) \
cargo build --locked -p codex-cli --bin codex -p codex-enterprise-server --bin codex-enterprise-server -p codex-app-server --bin codex-app-server \
&& install -m 0755 target/debug/codex /usr/local/bin/codex \
&& install -m 0755 target/debug/codex-enterprise-server /usr/local/bin/codex-enterprise-server \
&& install -m 0755 target/debug/codex-app-server /usr/local/bin/codex-app-server ;; \
*) echo "unsupported BUILD_PROFILE=$BUILD_PROFILE; use release or dev" >&2; exit 1 ;; \
esac
FROM debian:bookworm-slim AS runtime
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
bubblewrap \
ca-certificates \
curl \
git \
gnupg \
less \
openssh-client \
ripgrep \
zsh \
&& install -m 0755 -d /etc/apt/keyrings \
&& curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc \
&& chmod a+r /etc/apt/keyrings/docker.asc \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian bookworm stable" > /etc/apt/sources.list.d/docker.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
docker-buildx-plugin \
docker-ce-cli \
docker-compose-plugin \
docker-model-plugin \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/bin/codex /usr/local/bin/codex
COPY --from=builder /usr/local/bin/codex-enterprise-server /usr/local/bin/codex-enterprise-server
COPY --from=builder /usr/local/bin/codex-app-server /usr/local/bin/codex-app-server
COPY --chmod=0755 docker-entrypoint.sh /usr/local/bin/codex-container-entrypoint
RUN useradd --create-home --uid 1000 --shell /bin/zsh codex \
&& install -d -m 0755 -o codex -g codex /workspace /codex-home
USER codex
ENV CODEX_HOME=/codex-home
ENV HOME=/codex-home
WORKDIR /workspace
ENTRYPOINT ["codex-container-entrypoint"]