fix: better layering in docker image

This commit is contained in:
orion 2023-12-11 14:33:38 -06:00
parent 55457758ec
commit dbc8cd182a
Signed by: orion
GPG Key ID: 6D4165AE4C928719

View File

@ -52,9 +52,8 @@ RUN set -eo pipefail; \
apt-get update; \ apt-get update; \
apt-get install -y redis apt-get install -y redis
FROM system AS build FROM system AS next_prebuild
RUN asdf reshim
RUN npm i -g yarn RUN npm i -g yarn
RUN --mount=type=cache,target=/.yarn-cache \ RUN --mount=type=cache,target=/.yarn-cache \
yarn config set cache-folder /.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 packages packages
COPY web web COPY web web
COPY space space 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 \ RUN --mount=type=cache,target=/.yarn-cache \
--mount=type=cache,target=/web/.next \ --mount=type=cache,target=/web/.next \
--mount=type=cache,target=/space/.next \ --mount=type=cache,target=/space/.next \
yarn install && \
yarn build && \ yarn build && \
cp -R /web/.next /web/_next && \ cp -R /web/.next /web/_next && \
cp -R /space/.next /space/_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 /web/.next/standalone/web/* /web/ && \
cp -R /space/.next/standalone/space/* /space/ cp -R /space/.next/standalone/space/* /space/
FROM next_build AS api_build
ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1 ENV PYTHONUNBUFFERED=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 ENV PIP_DISABLE_PIP_VERSION_CHECK=1
COPY apiserver apiserver
RUN --mount=type=cache,target=/root/.cache/pip \ RUN --mount=type=cache,target=/root/.cache/pip \
cd /apiserver \ cd /apiserver \
&& pip install -r requirements.txt --compile && pip install -r requirements.txt --compile
FROM build AS s6 FROM api_build AS s6
COPY docker/etc/ /etc/ COPY docker/etc/ /etc/