-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile-dev
53 lines (42 loc) · 1.53 KB
/
Dockerfile-dev
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
###############
# BUILD IMAGE #
###############
FROM frolvlad/alpine-miniconda3:python3.7 AS build
# set working directory
WORKDIR /usr/src/app
# install packages
# clean
COPY ./docker/environment-dev.yml .
RUN conda update -n base conda && \
conda env create -f environment-dev.yml && \
conda clean -afy && \
find /opt/conda/ -follow -type f -name '*.a' -delete && \
find /opt/conda/ -follow -type f -name '*.pyc' -delete && \
find /opt/conda/ -follow -type f -name '*.js.map' -delete
#################
# RUNTIME IMAGE #
#################
FROM frolvlad/alpine-miniconda3:python3.7 AS runtime
# create user
ARG USER_ID
ARG GROUP_ID
# add non-root user and give permissions to workdir
RUN addgroup --gid $GROUP_ID user && \
adduser --gecos '' -D -u $USER_ID -G user user && \
mkdir -p /usr/src/app && \
chown -R user:user /usr/src/app
# copy from build image
RUN rm -rf /opt/conda
COPY --chown=user:user --from=build /opt/conda /opt/conda
# set working directory
WORKDIR /usr/src/app
# Make RUN commands use conda environment
SHELL ["conda", "run", "-n", "ds-ml", "/bin/sh", "-c"]
# copy custom Jupyter Lab settings
COPY ./jupyter-codemirror-settings.json /home/user/.jupyter/lab/user-settings/@jupyterlab/codemirror-extension/commands.jupyterlab-settings
# install jupyter lab vim keybindings for the notebooks
RUN jupyter labextension install jupyterlab_vim
# switch to non-root user
USER user
# run conda commands from environment
ENTRYPOINT ["conda", "run", "-n", "ds-ml"]