Skip to content

Commit

Permalink
Layer monobase:latest on top of monobase-runtime:latest
Browse files Browse the repository at this point in the history
  • Loading branch information
nevillelyh committed Jan 9, 2025
1 parent 88a3121 commit 3a001c4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 29 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
- run: ./script/build-image
- run: ./script/build-runtime-image
- run: ./script/test

test-mini:
Expand Down
16 changes: 3 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ RUN if $(git rev-parse --is-shallow-repository); then git fetch --unshallow; fi
&& echo "SETUPTOOLS_SCM_PRETEND_VERSION=${SETUPTOOLS_SCM_PRETEND_VERSION}" \
&& uv build --sdist --wheel

FROM ubuntu:jammy
FROM monobase-runtime:latest

ARG PREFIX=/srv/r8/monobase

ENV DEBIAN_FRONTEND=noninteractive
ENV MONOBASE_PREFIX=$PREFIX
ENV PATH=$MONOBASE_PREFIX/bin:$PATH
ENV PYTHONPATH=/opt/r8
ENV TZ=Etc/UTC
ENV UV_CACHE_DIR=$PREFIX/uv/cache
ENV UV_COMPILE_BYTECODE=true
ENV UV_LINK_MODE=hardlink
Expand All @@ -33,16 +29,10 @@ ENV UV_PYTHON_PREFERENCE=only-managed
ENV UV_TOOL_BIN_DIR=$PREFIX/bin
ENV UV_TOOL_DIR=$PREFIX/uv/tools

ADD ./apt-dependencies.txt /tmp/apt-dependencies.txt
RUN apt-get update \
&& apt-get install -y $(grep -v '^#' </tmp/apt-dependencies.txt) \
&& rm -rf /var/lib/apt/lists/* /tmp/apt-dependencies.txt

RUN --mount=type=bind,from=build,target=/tmp/build-layer,ro \
ln -sv /usr/bin/tini /sbin/tini \
&& mkdir -p /opt/r8/monobase /tmp/r8 \
mkdir -p /opt/r8/monobase /tmp/r8 \
&& tar --strip-components=1 -C /tmp/r8 -xf $(find /tmp/build-layer/src/dist -name '*.tar.gz' | head -1) \
&& cp -v /tmp/r8/src/monobase/*.sh /tmp/r8/src/monobase/pget /opt/r8/monobase/ \
&& cp -v /tmp/r8/src/monobase/build.sh /tmp/r8/src/monobase/pget /opt/r8/monobase/ \
&& rsync -av /tmp/r8/src/monobase/requirements /opt/r8/monobase/ \
&& find /tmp/build-layer/src/dist/ -type f \
&& cp -v $(find /tmp/build-layer/src/dist/ -name '*.whl' | head -1) /opt/r8/ \
Expand Down
14 changes: 8 additions & 6 deletions runtime.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
FROM ubuntu:jammy

ARG PREFIX=/srv/r8/monobase

ENV DEBIAN_FRONTEND=noninteractive
ENV MONOBASE_PREFIX=/srv/r8/monobase
ENV MONOBASE_PREFIX=$PREFIX
ENV PATH=$MONOBASE_PREFIX/bin:$PATH
ENV TZ=Etc/UTC

ADD ./apt-dependencies.txt /tmp/apt-dependencies.txt
RUN apt-get update \
&& apt-get install -y $(grep -v '^#' </tmp/apt-dependencies.txt) \
&& rm -rf /var/lib/apt/lists/* /tmp/apt-dependencies.txt
RUN --mount=type=bind,src=.,dst=/src,ro \
apt-get update \
&& apt-get install -y $(grep -v '^#' </src/apt-dependencies.txt) \
&& rm -rf /var/lib/apt/lists/*

RUN --mount=type=bind,src=../../,dst=/src,ro \
RUN --mount=type=bind,src=.,dst=/src,ro \
ln -sv /usr/bin/tini /sbin/tini \
&& mkdir -p /opt/r8/monobase \
&& ls -la /src/ \
Expand Down
7 changes: 6 additions & 1 deletion script/build-image
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
set -euo pipefail

cd "$(git rev-parse --show-toplevel)"

# monobase-runtime
docker build --file runtime.Dockerfile --tag monobase-runtime:latest --platform=linux/amd64 .

# monobase is layered on top of monobase-runtime
rm -vf ./dist/monobase*.*
uv build --sdist --wheel
exec docker build --tag monobase:latest --platform=linux/amd64 .
docker build --tag monobase:latest --platform=linux/amd64 .
8 changes: 0 additions & 8 deletions script/build-runtime-image

This file was deleted.

0 comments on commit 3a001c4

Please sign in to comment.