Skip to content

Instantly share code, notes, and snippets.

@twaddlac
Created July 19, 2022 13:37
Show Gist options
  • Save twaddlac/9c747afe8baf9673bb7245175de38897 to your computer and use it in GitHub Desktop.
Save twaddlac/9c747afe8baf9673bb7245175de38897 to your computer and use it in GitHub Desktop.
# Command I use to build the image
# docker buildx build --build-arg CONDA_PACKAGES=./envs/nsap_packages.txt --platform linux/amd64 -t alantwaddle/nsap_test:1.6 --push .
# (c) 2012 Continuum Analytics, Inc. / http://continuum.io
# All Rights Reserved
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Continuum Analytics, Inc. nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL CONTINUUM ANALYTICS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
FROM continuumio/miniconda3
LABEL author="Alan Twaddle"
LABEL author.email="alan.twaddle@neochromosome.com"
LABEL company="neochromosome"
# This is a text file listing a package name on each line.
ARG CONDA_PACKAGES
# Check this for conda in docker
# https://pythonspeed.com/articles/activate-conda-dockerfile/
COPY ${CONDA_PACKAGES} conda_packages.txt
# mamba is a faster package manager than conda. Redundant, yes,
# but the speed gain is > 100% when building this image
RUN conda install mamba -n base -c conda-forge
RUN conda create -n nsap
# Install packages with mamba
RUN mamba install -n nsap -y --file conda_packages.txt -c bioconda -c conda-forge
# Adding this command to the .bashrc ensures the environment is executed in a session
RUN echo "source activate nsap" > ~/.bashrc
# overrides the default shell to run in the conda env
SHELL ["conda", "run", "-n", "nsap", "/bin/bash", "-c"]
# Copying local python project and installing it locally
# TODO: Figure out how to do this with git.
COPY . /opt/nsap
WORKDIR /opt/nsap
RUN pip3 install -e .
# An AWS EBS storage volume is mounted here
WORKDIR /data
# This appends every command to it, again ensuring it runs in the conda env
ENTRYPOINT [ "conda", "run", "--no-capture-output", "-n", "nsap" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment