My streamlit application runs a set of subprocess calls to R. Hence, I need to use conda to install some of the requirements. Is there a way to do this? Is a docker container the only approach, or can I have conda as a requirement and then use it to install the R packages?
I managed to create a docker solution. Here’s the docker script I ended up with:
FROM continuumio/miniconda3
WORKDIR /code
# Create the environment:
COPY ./environment.yml /code/environment.yml
RUN conda config --set channel_priority strict
RUN conda config --add channels conda-forge
RUN conda env create -f environment.yml
# Make RUN commands use the new environment:
SHELL ["conda", "run", "-n", "plt_env", "/bin/bash", "-c"]
RUN pip install streamlit==1.22 Pillow lazyeval pandas
# Demonstrate the environment is activated:
RUN echo "Make sure streamlit is installed:"
RUN python -c "import streamlit; print('streamlit: ', streamlit.__version__)"
COPY . .
# The code to run when container is started:
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "plt_env", "streamlit", "run", "app.py", "--server.port", "7860", "--server.address", "0.0.0.0"]
Some of it is probably not required but it works.
1 Like
great @ludvigolsen , thanks for sharing your solution here. I’d also link your running Space here
1 Like