Skip to content

Instantly share code, notes, and snippets.

@atemate
Last active May 20, 2020 14:00
Show Gist options
  • Save atemate/6ff35581be803ff10765fef0a74548d6 to your computer and use it in GitHub Desktop.
Save atemate/6ff35581be803ff10765fef0a74548d6 to your computer and use it in GitHub Desktop.
Proposal: Flexible Neuro Base Image
ARG base_image
FROM ${base_image:-"neuromation/base:latest"}
# 1. Some Neuro Platform-common setup
# ===================================
# Force the stdout and stderr streams to be unbuffered.
# Needed for correct work of tqdm via 'neuro exec'
ENV PYTHONUNBUFFERED 1
# set some neuro-specific variables (for example, which
# would indicate that the job is adapted for Neuro Platform)
ENV NEURO_WHATEVER 1
# workaround for https://github.com/neuromation/platform-api/issues/1096
USER root
# 2. User-specific setup
# ======================
# install your own software (so that we will get rid of
# apt.txt, which is not flexible)
COPY setup.sh /var/neuro/setup.sh
RUN chmod +x /var/neuro/setup.sh && \
/var/neuro/setup.sh
COPY entrypoint.sh /var/neuro/entrypoint.sh
RUN chmod +x /var/neuro/entrypoint.sh
ENTRYPOINT ["bash", "/var/neuro/entrypoint.sh"]
#!/usr/bin/env bash
set -e
if [ ! -z "$EXPOSE_SSH" ]; then
echo "Starting SSH server"
/usr/sbin/sshd -e
fi
# TODO: is ldconfig really necessary?
ldconfig
if [ "$GCP_SERVICE_ACCOUNT_KEY_PATH" ]; then
gcloud auth activate-service-account --key-file "$GCP_SERVICE_ACCOUNT_KEY_PATH"
fi
if [ -f "$NM_WANDB_TOKEN_PATH" ]; then
wandb login "$(cat $NM_WANDB_TOKEN_PATH)"
fi
exec "$@"
#!/usr/bin/env bash
set -e
# This is example of setup.sh script
# install system dependencies:
apt-get update && apt-get install \
vim \
nano
# install pip dependencies, for example with a custom pip command:
pip install \
--progress-bar=off \
-f https://dl.fbaipublicfiles.com/detectron2/wheels/cu100/index.html \
-r requirements.txt
# install some custom software, for example apex:
cd /tmp && \
git clone https://github.com/NVIDIA/apex && \
cd apex && \
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment