Skip to content

Instantly share code, notes, and snippets.

@malcolmgreaves
Last active April 5, 2024 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malcolmgreaves/24ed54a5a78d14442f79f78f66326068 to your computer and use it in GitHub Desktop.
Save malcolmgreaves/24ed54a5a78d14442f79f78f66326068 to your computer and use it in GitHub Desktop.
A Dockerfile that installs conda. Uses a GPU-enabled image (with CUDA) as a base, but miniconda install & setup is portable.
# syntax=docker/dockerfile:1.3
ARG UBUNTU_VERSION=18.04
ARG CUDA_VERSION=11.3.1
# Or use a different image.
FROM nvidia/cuda:${CUDA_VERSION}-cudnn8-devel-ubuntu${UBUNTU_VERSION}
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# system packages #
# (ensure python & shared libs are present!) #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
RUN apt --allow-releaseinfo-change update -q && \
apt-get install -q -y \
bzip2 \
ca-certificates \
git \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1
wget \
nginx \
libcurl4-openssl-dev \
libssl-dev \
python3-dev \
gcc \
&& apt-get clean
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# install conda #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Miniconda
# https://github.com/ContinuumIO/docker-images/blob/4ed8fdac4647e4cc4210f84a327c3b7c92802b5d/miniconda3/debian/Dockerfile
ENV PATH /opt/conda/bin:$PATH
# Leave these args here to better use the Docker build cache
ARG CONDA_VERSION=py38_4.9.2
ARG CONDA_MD5=122c8c9beb51e124ab32a0fa6426c656
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh -O miniconda.sh && \
echo "${CONDA_MD5} miniconda.sh" > miniconda.md5 && \
if ! md5sum --status -c miniconda.md5; then exit 1; fi && \
mkdir -p /opt && \
sh miniconda.sh -b -p /opt/conda && \
rm miniconda.sh miniconda.md5 && \
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
echo "conda activate base" >> ~/.bashrc && \
find /opt/conda/ -follow -type f -name '*.a' -delete && \
find /opt/conda/ -follow -type f -name '*.js.map' -delete && \
/opt/conda/bin/conda clean -afy
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# can now use `conda` in RUN steps #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment