Last active
May 26, 2022 06:25
-
-
Save RainJayTsai/16979ee1687546f93827ba78e5657196 to your computer and use it in GitHub Desktop.
using docker BUILDKIT example, cache pip and mount temp whl to install. tensorflow python3.6
This file contains hidden or 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
# syntax = docker/dockerfile:experimental | |
FROM python:3.6 as base | |
###################################### | |
FROM base as builder | |
ENV PYTHONPATH=$PYTHONPATH:/install/lib/python3.6/site-packages/ | |
# bind a wheel and install it | |
# tensforflow build without avx | |
# https://github.com/RainJayTsai/tensorflow-build/releases/download/v1.12.1/tensorflow-1.12.1-cp36-cp36m-linux_x86_64.whl | |
RUN --mount=type=bind,target=/tensorflow-1.12.1-cp36-cp36m-linux_x86_64.whl,src=./tensorflow-1.12.1-cp36-cp36m-linux_x86_64.whl \ | |
--mount=type=cache,target=/root/.cache/pip \ | |
pip install --prefix /install /tensorflow-1.12.1-cp36-cp36m-linux_x86_64.whl | |
WORKDIR /tmp_install | |
# bind a pipenv and install | |
RUN --mount=type=bind,target=./Pipfile,src=./Pipfile \ | |
--mount=type=bind,target=./Pipfile.lock,src=./Pipfile.lock \ | |
--mount=type=cache,target=/root/.cache/pip \ | |
&& pip install pipenv \ | |
&& pipenv lock -r | sed 1d > ./requirements.txt \ | |
&& pip install --prefix /install -r ./requirements.txt | |
RUN --mount=type=cache,target=/root/.cache/pip \ | |
set -ex && ls -alg /root/.cache/pip && \ | |
pip install --prefix /install rasa-core && \ | |
ls -alg /root/.cache/pip | |
########################################################### | |
FROM python:3.6-slim as production | |
# copy install models and package to runtime image | |
COPY --from=builder /install/ /usr/local/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
export DOCKER_BUILDKIT=1
docker build --rm -t xxxx/image:tag .