Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
106 lines (99 loc) · 5.12 KB
/
Copy pathDockerfile
File metadata and controls
106 lines (99 loc) · 5.12 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
FROM oven/bun:1.4.0 AS bun
FROM docker:29-cli AS docker-cli
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 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 \
&& cp -R out/main/agent-tools /opt/theoremos-agent-tools \
&& 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
USER 10001:10001
LABEL org.theoremos.native-team-workflow=v2
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 out/web ./out/web
COPY out/web-report ./out/web-report
ARG THEOREMOS_SOURCE_COMMIT=unknown
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"]