-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile-multistage
103 lines (90 loc) · 3.57 KB
/
Dockerfile-multistage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# >>>>>>>>>>>>>>>>>>>>>>>>>>>
# Auto-generated by agi-pack (version=0.2.0).
FROM debian:buster-slim AS base-cpu
# Setup environment variables
ENV AGIPACK_PROJECT agi
ENV AGIPACK_PYENV agi-py38
ENV AGIPACK_PATH /opt/agi-pack
ENV DEBIAN_FRONTEND="noninteractive"
ENV PYTHON_VERSION 3.8.10
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PYTHONWARNINGS ignore
ENV PIP_CACHE_DIR /var/cache/pip
ENV CONDA_PKGS_DIRS /var/cache/conda/pkgs
# Setup conda paths
ENV CONDA_PATH=${AGIPACK_PATH}/conda/envs/${AGIPACK_PYENV}
ENV CONDA_PREFIX=${CONDA_PATH}
ENV CONDA_EXE=${CONDA_PATH}/bin/conda
ENV PATH=${CONDA_PATH}/bin:${AGIPACK_PATH}/conda/bin:$PATH
ENV CONDA_DEFAULT_ENV ${AGIPACK_PYENV}
# Install base system packages
RUN apt-get -y update \
&& apt-get -y --no-install-recommends install \
curl bzip2 git ca-certificates
# Install additional system packages
RUN --mount=type=cache,target=/var/cache/apt \
apt-get -y update \
&& apt-get -y --no-install-recommends install \
wget \
&& echo "system install complete"
# Install mambaforge, with cache mounting ${CONDA_PKGS_DIRS} for faster builds
RUN --mount=type=cache,target=${CONDA_PKGS_DIRS} \
curl -sLo ~/mambaforge.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh" \
&& chmod +x ~/mambaforge.sh \
&& ~/mambaforge.sh -b -p ${AGIPACK_PATH}/conda \
&& ${AGIPACK_PATH}/conda/bin/mamba init bash \
&& ${AGIPACK_PATH}/conda/bin/mamba config --add channels conda-forge \
&& ${AGIPACK_PATH}/conda/bin/mamba create -n ${AGIPACK_PYENV} python=${PYTHON_VERSION} -y \
&& rm ~/mambaforge.sh
# Upgrade pip
RUN pip install --upgrade pip
# Install pip packages, with cache mounting ${PIP_CACHE_DIR} for faster builds
# Note: Cache mounts allow us to re-use the cache for pip packages
# instead of having to re-download them every time we build.
RUN --mount=type=cache,target=${PIP_CACHE_DIR} \
pip install --cache-dir ${PIP_CACHE_DIR} \
"scikit-learn" \
&& echo "pip install complete"
# Export conda environment on login
RUN echo "export CONDA_PATH=${AGIPACK_PATH}/conda/envs/${AGIPACK_PYENV}" >> ~/.bashrc \
&& echo "export PATH=${AGIPACK_PATH}/conda/envs/${AGIPACK_PYENV}/bin:$PATH" >> ~/.bashrc \
&& echo "export CONDA_DEFAULT_ENV=${AGIPACK_PYENV}" >> ~/.bashrc \
&& echo "mamba activate ${AGIPACK_PYENV}" > ~/.bashrc
# Setup working directory
WORKDIR /app/$AGIPACK_PYENV
# Run commands
RUN echo "running commands"
RUN --mount=type=cache,target=${CONDA_PKGS_DIRS} \
--mount=type=cache,target=${PIP_CACHE_DIR} \
echo "Hello, world!"
RUN echo "run commands complete"
# Cleanup apt, mamba/conda and pip packages
RUN apt-get -y autoclean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/* \
&& ${AGIPACK_PATH}/conda/bin/mamba clean -ya \
&& rm -rf ${PIP_CACHE_DIR} \
&& rm -rf ${CONDA_PKGS_DIRS} \
&& rm -rf /tmp/reqs \
&& echo "pip cleanup complete"
# >>>>>>>>>>>>>>>>>>>>>>>>>>>
# Auto-generated by agi-pack (version=0.2.0).
FROM base-cpu AS dev-cpu
# Install additional system packages
RUN --mount=type=cache,target=/var/cache/apt \
apt-get -y update \
&& apt-get -y --no-install-recommends install \
build-essential \
&& echo "system install complete"
# Setup working directory
WORKDIR /app/$AGIPACK_PYENV
# Cleanup apt, mamba/conda and pip packages
RUN apt-get -y autoclean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/* \
&& ${AGIPACK_PATH}/conda/bin/mamba clean -ya \
&& rm -rf ${PIP_CACHE_DIR} \
&& rm -rf ${CONDA_PKGS_DIRS} \
&& rm -rf /tmp/reqs \
&& echo "pip cleanup complete"