Skip to content

Commit

Permalink
Merge pull request #1638 from consideRatio/main
Browse files Browse the repository at this point in the history
helm-chart: refactor Dockerfile to make it obvious we don't fail to pass built wheels
  • Loading branch information
consideRatio committed Mar 24, 2023
2 parents 4893dd8 + 8cac969 commit 187c22f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions helm-chart/images/binderhub/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

# The build stage
# ---------------
# This stage is building Python wheels for use in later stages by using a base
# image that has more pre-requisites to do so, such as a C++ compiler.
#
# NOTE: If the image version is updated, also update it in ci/refreeze!
#
FROM python:3.11-bullseye as build-stage
WORKDIR /build-stage

# install node as required to build a binderhub wheel
RUN echo "deb https://deb.nodesource.com/node_16.x bullseye main" > /etc/apt/sources.list.d/nodesource.list \
Expand All @@ -17,19 +18,26 @@ RUN apt-get update \
nodejs \
&& rm -rf /var/lib/apt/lists/*

# build wheels to be mounted through a cache in the final stage
ARG PIP_CACHE_DIR=/tmp/pip-cache
# Build wheels
#
# We set pip's cache directory and expose it across build stages via an
# ephemeral docker cache (--mount=type=cache,target=${PIP_CACHE_DIR}). We use
# the same technique for the directory /tmp/wheels.
#
COPY . .
ARG PIP_CACHE_DIR=/tmp/pip-cache
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
pip install build \
&& pip wheel \
&& pip wheel --wheel-dir=/tmp/wheels \
. \
pycurl \
-r helm-chart/images/binderhub/requirements.txt


# The final stage
# ---------------
# This stage is built and published as jupyterhub/k8s-binderhub.
#
FROM python:3.11-slim-bullseye

ENV PYTHONUNBUFFERED=1
Expand All @@ -50,10 +58,10 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

# install wheels built in the build stage
ARG PIP_CACHE_DIR=/tmp/pip-cache
COPY helm-chart/images/binderhub/requirements.txt /tmp/requirements.txt
ARG PIP_CACHE_DIR=/tmp/pip-cache
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
--mount=type=cache,from=build-stage,source=/build-stage,target=/tmp/wheels \
--mount=type=cache,from=build-stage,source=/tmp/wheels,target=/tmp/wheels \
pip install --find-links=/tmp/wheels/ \
binderhub \
pycurl \
Expand Down

0 comments on commit 187c22f

Please sign in to comment.