-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
41 lines (40 loc) · 1.54 KB
/
Dockerfile
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
ARG MICROMAMBA_VERSION="2.0.2"
ARG ENVIRONMENT_FILE="env.yaml"
ARG NOTEBOOK_MODE
# Stage 1
FROM mambaorg/micromamba:${MICROMAMBA_VERSION} AS micromamba-patched
ARG MICROMAMBA_VERSION
ARG ENVIRONMENT_FILE
ARG NOTEBOOK_MODE
# Install security updates if base image is not yet patched
# Inspired by https://pythonspeed.com/articles/security-updates-in-docker/
USER root
RUN apt-get update && apt-get -y upgrade
# ENTRYPOINT ["/usr/local/bin/_entrypoint.sh"]
# cat /etc/apt/sources.list
# WORKDIR /etc/apt/
USER $MAMBA_USER
# Stage 2
FROM micromamba-patched
ARG ENVIRONMENT_FILE
ARG NOTEBOOK_MODE
USER $MAMBA_USER
# ENV ENVIRONMENT_FILE=${ENVIRONMENT_FILE}
ENV NOTEBOOK_MODE=${NOTEBOOK_MODE}
COPY --chown=$MAMBA_USER:$MAMBA_USER ${ENVIRONMENT_FILE} /tmp/env.yaml
# Install packages
# The name of the environment will always be "base", irrespective of the YAML file
# This is due to the way micromamba-docker works
RUN micromamba install -y -n base -f /tmp/env.yaml && \
micromamba clean --all --yes
WORKDIR /usr/app/src
# TODO: This is not needed for notebook images
COPY --chown=$MAMBA_USER:$MAMBA_USER src/ ./
ARG MAMBA_DOCKERFILE_ACTIVATE=1
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh"]
# Add the base environment as the default Jupyter Python kernel
RUN if [[ -n "$NOTEBOOK_MODE" ]] ; then python -m ipykernel install --user ; fi
# For debugging, use this one
# ENTRYPOINT ["/usr/local/bin/_entrypoint.sh", "/bin/bash"]
# In a final application, you may want to hard-wire the entrypoint to the script:
# ENTRYPOINT ["/usr/local/bin/_entrypoint.sh", "python", "./main.py"]