From dbc8cd182a98f229abe68efb4c1ac6cd81aceaf0 Mon Sep 17 00:00:00 2001 From: Orion Kindel Date: Mon, 11 Dec 2023 14:33:38 -0600 Subject: [PATCH] fix: better layering in docker image --- Dockerfile | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index da536c2fb..7245c0a09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,9 +52,8 @@ RUN set -eo pipefail; \ apt-get update; \ apt-get install -y redis -FROM system AS build +FROM system AS next_prebuild -RUN asdf reshim RUN npm i -g yarn RUN --mount=type=cache,target=/.yarn-cache \ yarn config set cache-folder /.yarn-cache @@ -63,11 +62,15 @@ COPY package.json turbo.json yarn.lock app.json ./ COPY packages packages COPY web web COPY space space -COPY apiserver apiserver + +RUN --mount=type=cache,target=/.yarn-cache \ + yarn install + +FROM next_prebuild AS next_build + RUN --mount=type=cache,target=/.yarn-cache \ --mount=type=cache,target=/web/.next \ --mount=type=cache,target=/space/.next \ - yarn install && \ yarn build && \ cp -R /web/.next /web/_next && \ cp -R /space/.next /space/_next @@ -77,15 +80,17 @@ RUN mv /web/_next /web/.next && \ cp -R /web/.next/standalone/web/* /web/ && \ cp -R /space/.next/standalone/space/* /space/ +FROM next_build AS api_build ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 ENV PIP_DISABLE_PIP_VERSION_CHECK=1 +COPY apiserver apiserver RUN --mount=type=cache,target=/root/.cache/pip \ cd /apiserver \ && pip install -r requirements.txt --compile -FROM build AS s6 +FROM api_build AS s6 COPY docker/etc/ /etc/