Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
131 lines (123 loc) · 6.71 KB
/
Copy pathDockerfile
File metadata and controls
131 lines (123 loc) · 6.71 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
FROM oven/bun:1.4.0 AS bun
FROM docker:29-cli AS docker-cli
# Compile against the worker's libc; a binary from the development host may
# require a newer glibc even when the Codex source and architecture match.
FROM rust:1.99.1-bookworm AS codex-backend
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 curl cmake pkg-config libssl-dev libcap-dev libasound2-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY scripts/build-codex-backend.sh scripts/build-codex-backend.sh
COPY scripts/codex-backend/ scripts/codex-backend/
ARG CODEX_BUILD_JOBS=4
RUN --mount=type=cache,id=theoremos-codex-registry,target=/usr/local/cargo/registry,sharing=locked \
--mount=type=cache,id=theoremos-codex-git,target=/usr/local/cargo/git,sharing=locked \
--mount=type=cache,id=theoremos-bookworm-codex-target,target=/build/artifacts/target,sharing=locked \
bash scripts/build-codex-backend.sh --source /build/upstream --downloads /build/downloads \
--output /build/artifacts --jobs "$CODEX_BUILD_JOBS"
FROM node:22-bookworm-slim AS base
COPY --from=bun /usr/local/bin/bun /usr/local/bin/bun
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl git python3 util-linux bubblewrap elan \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt/theorem-os
COPY package.json bun.lock tsconfig.json extraction.json ./
RUN bun install --frozen-lockfile
FROM base AS source
COPY bin ./bin
COPY src ./src
COPY scripts ./scripts
COPY skills ./skills
COPY resources ./resources
COPY apps ./apps
COPY docs/assets ./docs/assets
COPY LICENSE NOTICE CITATION.cff ./
COPY LICENSES ./LICENSES
COPY third_party ./third_party
# A small, independent image for untrusted LaTeX snapshots. It deliberately has no project source or network client.
FROM debian:bookworm-slim AS tex
ARG THEOREMOS_SOURCE_COMMIT=unknown
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates fontconfig latexmk python3 texlive-fonts-recommended \
texlive-latex-recommended texlive-xetex \
&& rm -rf /var/lib/apt/lists/* \
&& useradd --system --uid 10001 --create-home --home-dir /work --shell /usr/sbin/nologin theorem \
&& chmod 0700 /work
ENV HOME=/tmp TEXMFCONFIG=/tmp/texmf-config TEXMFVAR=/tmp/texmf-var XDG_CACHE_HOME=/tmp/cache
WORKDIR /work
USER 10001:10001
LABEL org.opencontainers.image.revision=$THEOREMOS_SOURCE_COMMIT
ENTRYPOINT ["sh"]
FROM base AS worker-tools
ENV ELAN_HOME=/opt/elan \
PATH=/opt/elan/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin \
HOME=/work/home \
DEEPSCIENTIST_MATH_SANDBOX_BACKEND=bwrap \
DEEPSCIENTIST_MATH_TRUSTED_ELAN_ROOTS=/opt/elan
COPY scripts/install-elan.sh ./scripts/install-elan.sh
RUN npm install --global @openai/codex@0.172.0 \
&& sh scripts/install-elan.sh \
&& elan toolchain install leanprover/lean4:v4.36.0 \
&& chmod -R a+rX /opt/elan \
&& mkdir -p /work && chown 10001:10001 /work \
&& install -d -o 10001 -g 10001 -m 0700 /var/theoremos-proof
FROM worker-tools AS worker-mathlib
RUN apt-get -o Acquire::Retries=3 update && apt-get install -y --no-install-recommends \
build-essential fuse3 squashfuse squashfs-tools \
&& rm -rf /var/lib/apt/lists/*
COPY resources/mathlib/environment.json ./resources/mathlib/environment.json
COPY scripts/prepare-web-mathlib.ts ./scripts/prepare-web-mathlib.ts
RUN --mount=type=cache,id=theoremos-mathlib-v4.36.0,target=/var/cache/theoremos-mathlib,sharing=locked \
MATHLIB_CACHE_DIR=/var/cache/theoremos-mathlib bun scripts/prepare-web-mathlib.ts \
&& chmod -R a+rX /opt/theoremos-mathlib \
&& chown 10001:10001 /var/tmp && chmod 0700 /var/tmp
COPY scripts/build-pantograph.ts ./scripts/build-pantograph.ts
COPY scripts/pantograph/ ./scripts/pantograph/
RUN bun scripts/build-pantograph.ts /opt/theoremos-pantograph
FROM worker-mathlib AS worker
ENV TMPDIR=/tmp \
PATH=/opt/elan/toolchains/leanprover--lean4---v4.36.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin \
DEEPSCIENTIST_MATH_TRUSTED_ELAN_ROOTS=/opt/elan/toolchains/leanprover--lean4---v4.36.0 \
DEEPSCIENTIST_MATH_TRUSTED_CACHE_ROOTS=/opt/theoremos-mathlib/.lake/packages
COPY --from=source /opt/theorem-os /opt/theorem-os
RUN bun scripts/prepare-web-library.ts \
&& chmod -R a+rX /opt/theoremos-library
# Use the installed binaries directly: the verifier mounts the toolchain read-only.
# Agent shells cannot read /opt/theorem-os or /opt/runtime-state; they run the bundled commands instead.
RUN bun scripts/build.ts --state-root /opt/runtime-state > /opt/theoremos-build.json \
&& bun scripts/build-agent-tools.ts --out /opt/theoremos-agent-tools > /dev/null \
&& bun scripts/build-proof-environment-seed.ts --project /opt/theoremos-mathlib \
--packages /opt/theoremos-mathlib/.lake/packages --out /opt/theoremos-proof-environment-seed \
&& bun scripts/build-proof-environment-seed.ts --project /opt/theoremos-mathlib \
--packages /opt/theoremos-mathlib/.lake/packages --out /opt/theoremos-proof-source-seed --sources-only \
&& chmod -R a+rX /opt/runtime-state /opt/theoremos-agent-tools \
&& chmod 0555 apps/web/worker-entrypoint.sh
ENV DEEPSCIENTIST_MATH_PROOF_ENVIRONMENT_SEED=/opt/theoremos-proof-environment-seed/manifest.json
ENV DEEPSCIENTIST_MATH_PROOF_ENVIRONMENT_SOURCE_SEED=/opt/theoremos-proof-source-seed/manifest.json
# The source commit this image was built from (scripts/web-deploy-record.sh records it with the image digests).
ARG THEOREMOS_SOURCE_COMMIT=unknown
LABEL org.opencontainers.image.revision=$THEOREMOS_SOURCE_COMMIT
ENV THEOREMOS_SOURCE_COMMIT=$THEOREMOS_SOURCE_COMMIT
COPY --from=codex-backend /build/artifacts/bin/codex /opt/theoremos-codex-backend/codex
COPY --from=codex-backend /build/artifacts/bin/codex-code-mode-host /opt/theoremos-codex-backend/codex-code-mode-host
ENV THEOREMOS_CODEX_BACKEND_EXECUTABLE=/opt/theoremos-codex-backend/codex
USER 10001:10001
RUN timeout 30s python3 scripts/codex-backend/check-capabilities.py "$THEOREMOS_CODEX_BACKEND_EXECUTABLE"
LABEL org.theoremos.native-agent-control=v1
LABEL org.theoremos.native-team-workflow=v1
LABEL org.theoremos.team-profile-preferences=v1
LABEL org.theoremos.team-expert-cards=v1
LABEL org.theoremos.worker-control=v1
ENTRYPOINT ["/opt/theorem-os/apps/web/worker-entrypoint.sh"]
FROM source AS web
COPY --from=docker-cli /usr/local/bin/docker /usr/local/bin/docker
COPY docs/web ./docs/web
COPY docs/archive.html docs/site.css docs/process.css docs/replay.css ./docs/
COPY docs/en/archive.html ./docs/en/archive.html
COPY research/openai-math ./research/openai-math
ARG THEOREMOS_SOURCE_COMMIT=unknown
RUN bun scripts/build-web.ts
LABEL org.opencontainers.image.revision=$THEOREMOS_SOURCE_COMMIT
ENV THEOREMOS_WEB_HOST=0.0.0.0 THEOREMOS_WEB_PORT=8787 THEOREMOS_SOURCE_COMMIT=$THEOREMOS_SOURCE_COMMIT
EXPOSE 8787
CMD ["bun", "apps/web/server.ts"]