Skip to content

Commit

Permalink
Simplify Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
maresb committed Feb 22, 2024
1 parent 3b361a2 commit 03e4b88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
31 changes: 4 additions & 27 deletions scripts/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,9 @@ LABEL description="Environment for PyMC Marketing"

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8

# Switch to jovyan to avoid container runs as root
USER $NB_UID

# Install conda environment
COPY /scripts/docker/environment-dev.yml .
RUN mamba env create -f environment-dev.yml && \
/bin/bash -c ". activate pymc-marketing-dev" && \
mamba clean --all -f -y

# Create kernel
RUN $CONDA_DIR/envs/pymc-marketing-dev/bin/python -m ipykernel install --user --name=pymc-marketing-dev

# Prepend conda environment to path
ENV PATH $CONDA_DIR/envs/pymc-marketing-dev/bin:$PATH

# If you want this environment to be the default one, uncomment the following line:
ENV CONDA_DEFAULT_ENV pymc-marketing-dev

# Setup working folder
WORKDIR /home/jovyan/work

# For running from bash
SHELL ["/bin/bash","-c"]
RUN echo "mamba activate pymc-marketing-dev" >> ~/.bashrc && \
source ~/.bashrc
COPY environment-dev.yml /tmp/

# For running from jupyter notebook
EXPOSE 8888
CMD ["mamba", "run", "--no-capture-output", "-n", "pymc-marketing-dev", "jupyter","notebook","--ip=0.0.0.0","--port=8888","--no-browser"]
RUN mamba env update -n base -f /tmp/environment-dev.yml && \
conda clean --all -f -y && \
fix-permissions $CONDA_DIR
4 changes: 3 additions & 1 deletion scripts/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
To build the docker image, run the following command:

```bash
docker build -f scripts/docker/Dockerfile -t docker-pymc-marketing .
cd scripts/docker/
docker build -t docker-pymc-marketing .
```

To run the docker image, run the following command:

```bash
cd /path/to/your/project
docker run -it -p 8888:8888 -v $(pwd):/home/jovyan/work docker-pymc-marketing
```

Expand Down

0 comments on commit 03e4b88

Please sign in to comment.