-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile-builder
67 lines (58 loc) · 2.38 KB
/
Dockerfile-builder
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
# >>>>>>>>>>>>>>>>>>>>>>>>>>>
# Auto-generated by agi-pack (version=0.2.0).
FROM debian:buster-slim AS agipack-builder
# Setup environment variables
ENV AGIPACK_PROJECT agipack
ENV AGIPACK_PYENV agipack-py38
ENV AGIPACK_PATH /opt/agi-pack
ENV DEBIAN_FRONTEND="noninteractive"
ENV PYTHON_VERSION 3.8
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 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
# 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} \
pip install agi-pack
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"
CMD ["agi-pack", "generate", "-f"]