-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to cosmopolitan 3.1.1, simplify bootstrap
We now only use "uname" from busybox... Everything else is pulled from cosmos binaries themselves.
- Loading branch information
Showing
3 changed files
with
128 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,105 @@ | ||
# syntax=docker/dockerfile:1-labs | ||
|
||
FROM busybox as unpack-cosmos | ||
ADD --checksum=sha256:ce256ededf106748a09f13bf47ace9ef0e6f115d963353d3d63c21302c5f28f4 https://github.com/jart/cosmopolitan/releases/download/3.0.1/cosmos-3.0.1.zip /dl/ | ||
FROM busybox as busybox | ||
|
||
# define a starting point "scratch" image that can run APEs | ||
FROM scratch as cosmos-scratch | ||
COPY --from=busybox /bin/uname /usr/bin/ | ||
ADD --chmod=0755 https://cosmo.zip/pub/cosmos/bin/assimilate-x86_64.elf /usr/bin/ | ||
ADD --chmod=0755 https://cosmo.zip/pub/cosmos/bin/dash /bin/sh | ||
RUN ["/usr/bin/assimilate-x86_64.elf", "-c", "/bin/sh"] | ||
ADD --checksum=sha256:abf3b1bb7182935bf48d98dc143c51ee563d29a1fd2c3930ff5a8d8c8d823817 --chmod=0755 https://justine.lol/ape.elf /usr/bin/ape | ||
ENV PATH=/bin:/usr/bin | ||
|
||
# download and unpack all the cosmos binaries | ||
FROM cosmos-scratch as unpack-cosmos | ||
ADD --chmod=0755 https://cosmo.zip/pub/cosmos/bin/unzip /usr/bin/ | ||
RUN ["/usr/bin/assimilate-x86_64.elf", "-c", "/usr/bin/unzip"] | ||
ADD https://cosmo.zip/pub/cosmos/zip/cosmos.zip /dl/ | ||
|
||
# list of binaries that must be assimilated and manifest for /bin as described in https://justine.lol/cosmos.txt (as of 2023-11-29) | ||
WORKDIR /opt/cosmos | ||
RUN ["/bin/unzip", "/dl/cosmos-3.0.1.zip"] | ||
RUN ["/bin/cp", "bin/dash", "bin/sh"] | ||
RUN unzip /dl/cosmos.zip | ||
WORKDIR /opt/cosmos/bin | ||
RUN /usr/bin/assimilate-x86_64.elf -c dd \ | ||
&& /usr/bin/assimilate-x86_64.elf -c cp \ | ||
&& /usr/bin/assimilate-x86_64.elf -c mv \ | ||
&& /usr/bin/assimilate-x86_64.elf -c echo \ | ||
&& /usr/bin/assimilate-x86_64.elf -c uname \ | ||
&& /usr/bin/assimilate-x86_64.elf -c mkdir \ | ||
&& /usr/bin/assimilate-x86_64.elf -c chmod \ | ||
&& /usr/bin/assimilate-x86_64.elf -c gzip \ | ||
&& /usr/bin/assimilate-x86_64.elf -c printf \ | ||
# assimilate these so the build works on github actions... | ||
&& /usr/bin/assimilate-x86_64.elf -c rmdir \ | ||
&& /usr/bin/assimilate-x86_64.elf -c ln \ | ||
&& /usr/bin/assimilate-x86_64.elf -c tar \ | ||
&& /usr/bin/assimilate-x86_64.elf -c unzip | ||
RUN ./mv '[' bash cat chgrp chmod chown cksum cp date df echo false grep kill ln ls mkdir mknod mktemp mv nice printenv pwd rm rmdir sed sleep stat sync touch true uname /bin/ \ | ||
&& /bin/mv * /usr/bin/ | ||
WORKDIR / | ||
RUN rmdir /opt/cosmos/bin /opt/cosmos | ||
|
||
ENTRYPOINT ["/bin/sh", "-c", "exec \"$@\"", "sh"] | ||
CMD ["/bin/bash"] | ||
|
||
FROM busybox as unpack-cosmo | ||
ADD --checksum=sha256:2872d2f06ef5fd13a206d3ba7a9ef29eb9bd8ebfe9600a35d5c55a88ffd112df https://github.com/jart/cosmopolitan/releases/download/3.0.1/cosmopolitan-3.0.1.tar.gz /dl/ | ||
ADD --checksum=sha256:e222b38b53b999e3310a2e172a75992a28b1594af5c1e954c913fc54405c1135 https://github.com/jart/cosmopolitan/releases/download/3.0.1/cosmocc-0.0.16.zip /dl/ | ||
# download and unpack the cosmo source code | ||
FROM cosmos-scratch as unpack-cosmo | ||
ADD --checksum=sha256:8d1058afcd6f32f5e7edb708c0a3014d544a4b17d35449be71fbfdd2a1eb39ba https://github.com/jart/cosmopolitan/releases/download/3.1.1/cosmopolitan-3.1.1.tar.gz /dl/ | ||
WORKDIR /opt/cosmo | ||
RUN ["/bin/tar", "-xf", "/dl/cosmopolitan-3.0.1.tar.gz", "--strip-components=1"] | ||
RUN ["/bin/unzip", "/dl/cosmocc-0.0.16.zip"] | ||
WORKDIR /usr/bin | ||
RUN ["/bin/ln", "-s", "/opt/cosmo/bin/cosmocc", "cc"] | ||
RUN ["/bin/ln", "-s", "/opt/cosmo/bin/cosmocc", "gcc"] | ||
COPY --from=unpack-cosmos /usr/bin/tar /usr/bin/gzip /usr/bin/ | ||
RUN /usr/bin/tar --strip-components=1 -xf /dl/cosmopolitan-3.1.1.tar.gz | ||
|
||
FROM busybox as busybox | ||
# download and unpack the cosmocc toolchain | ||
FROM cosmos-scratch as unpack-cosmocc | ||
ADD --checksum=sha256:fa982741f52a2199194b9f06229729eb1eb220d065b0a65cca6dec3b36a9c7df https://github.com/jart/cosmopolitan/releases/download/3.1.1/cosmocc-3.1.1.zip /dl/ | ||
WORKDIR /opt/cosmocc | ||
COPY --from=unpack-cosmos /usr/bin/unzip /usr/bin/ | ||
RUN /usr/bin/unzip /dl/cosmocc-3.1.1.zip | ||
|
||
# Create the final image from scratch | ||
FROM scratch | ||
# We need sh and uname for cosmos at runtime. | ||
COPY --from=busybox /bin/uname /bin/ | ||
ADD --checksum=sha256:e67d07bb3010cad678c02fbc787c360340060467ebb39d681b58389df40fc904 --chmod=0755 https://justine.lol/dash /bin/sh | ||
ADD --checksum=sha256:2789991dd41483961a753040ffc083c0c5ff24b84c09a02892e5c584a3f8effa --chmod=0755 https://justine.lol/ape.elf /usr/bin/ape | ||
# an image that suppoers a single APE | ||
FROM cosmos-scratch as ape | ||
# can be /usr/bin/python /usr/bin/qjs /usr/bin/sqlite3 /usr/bin/lua | ||
ARG COSMOS_EXE=/usr/bin/python | ||
LABEL org.opencontainers.image.source https://github.com/ajbouh/cosmos | ||
COPY --from=unpack-cosmos ${COSMOS_EXE} ${COSMOS_EXE} | ||
ENV PATH=/bin:/usr/bin | ||
ENV COSMOS_EXE="${COSMOS_EXE}" | ||
ENTRYPOINT ["/bin/sh", "-c", "exec \"$@\"", "sh"] | ||
CMD "${COSMOS_EXE}" | ||
|
||
# define the final image in as few layers as possible | ||
FROM cosmos-scratch as cosmos | ||
LABEL org.opencontainers.image.source https://github.com/ajbouh/cosmos | ||
COPY --from=unpack-cosmos /bin /bin | ||
COPY --from=unpack-cosmos /usr/bin /usr/bin | ||
COPY --from=unpack-cosmo /opt/cosmo /opt/cosmo | ||
COPY --from=unpack-cosmo /usr/bin/cc /usr/bin/gcc /usr/bin/ | ||
COPY --from=unpack-cosmos /opt/cosmos /opt/cosmos | ||
COPY --from=unpack-cosmocc /opt/cosmocc /opt/cosmocc | ||
ENV PATH=/bin:/usr/bin:/opt/cosmocc/bin | ||
RUN /bin/ln -s /opt/cosmocc/bin/cosmocc /usr/bin/cc \ | ||
&& /bin/ln -s /opt/cosmocc/bin/cosmocc /usr/bin/gcc | ||
ENTRYPOINT ["/bin/sh", "-c", "exec \"$@\"", "sh"] | ||
CMD ["/bin/bash"] | ||
|
||
ENV PATH=/bin:/usr/bin:/opt/cosmo/bin:/opt/cosmos/bin | ||
# RUN ["/opt/cosmo/bin/cosmocc", "--update"] | ||
# FROM cosmos-scratch as python-pip-cli | ||
# ARG COSMOS_EXE=/usr/bin/python | ||
# ARG COSMOS_PIP_INSTALL="huggingface_hub[cli]" | ||
# ARG COSMOS_PIP_BINSTUB="huggingface-cli" | ||
# LABEL org.opencontainers.image.source https://github.com/ajbouh/cosmos | ||
# COPY --from=unpack-cosmos ${COSMOS_EXE} ${COSMOS_EXE} | ||
# ENV PATH=/bin:/usr/bin | ||
# ENV COSMOS_EXE="${COSMOS_EXE}" | ||
# ENV COSMOS_PIP_BINSTUB="${COSMOS_PIP_BINSTUB}" | ||
# RUN python -m pip install --user --no-cache-dir ${COSMOS_PIP_INSTALL} | ||
# ENTRYPOINT ["/bin/sh", "-c", "exec \"$@\"", "sh"] | ||
# CMD "${COSMOS_EXE}" "/.local/bin/${COSMOS_PIP_BINSTUB}" | ||
|
||
ENTRYPOINT ["/bin/sh", "-c"] | ||
CMD ["/opt/cosmos/bin/bash"] | ||
LABEL org.opencontainers.image.source https://github.com/ajbouh/cosmos | ||
# COPY --from=unpack-cosmos /bin/ /bin/ | ||
# COPY --from=unpack-cosmos /usr/bin/ /usr/bin/ | ||
# CMD /bin/bash | ||
|
||
# FROM cosmos-scratch as mistral-7b-instruct-v0.1-Q4_K_M-main | ||
# LABEL org.opencontainers.image.source https://github.com/ajbouh/cosmos | ||
# COPY --chmod=0755 mistral-7b-instruct-v0.1-Q4_K_M-main.llamafile /usr/bin/mistral-7b-instruct-v0.1-Q4_K_M-main.llamafile | ||
# ENV PATH=/bin:/usr/bin | ||
# ENTRYPOINT ["/bin/sh", "-c", "exec \"$@\"", "sh", "/usr/bin/mistral-7b-instruct-v0.1-Q4_K_M-main.llamafile"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,35 @@ | ||
version: "3.0" | ||
services: | ||
cosmos: | ||
image: ghcr.io/ajbouh/cosmos:3.1.1 | ||
build: | ||
dockerfile: Dockerfile | ||
target: cosmos | ||
python: | ||
image: ghcr.io/ajbouh/cosmos:python-cosmo-3.1.1 | ||
build: | ||
dockerfile: Dockerfile | ||
target: ape | ||
args: | ||
COSMOS_EXE: /usr/bin/python | ||
lua: | ||
image: ghcr.io/ajbouh/cosmos:lua-cosmo-3.1.1 | ||
build: | ||
dockerfile: Dockerfile | ||
target: ape | ||
args: | ||
COSMOS_EXE: /usr/bin/lua | ||
sqlite3: | ||
image: ghcr.io/ajbouh/cosmos:sqlite3-cosmo-3.1.1 | ||
build: | ||
dockerfile: Dockerfile | ||
target: ape | ||
args: | ||
COSMOS_EXE: /usr/bin/sqlite3 | ||
qjs: | ||
image: ghcr.io/ajbouh/cosmos:qjs-cosmo-3.1.1 | ||
build: | ||
dockerfile: Dockerfile | ||
target: ape | ||
args: | ||
COSMOS_EXE: /usr/bin/qjs |