0

I am new to dockerization and I am trying to make a docker image out of git repository. The Dockerfile looks like this,

FROM continuumio/miniconda3:latest
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

WORKDIR /fire_danger_tool
COPY . /fire_danger_tool/.
SHELL ["/bin/bash", "--login", "-c"]
RUN apt update
RUN apt install -y build-essential gfortran
RUN conda init
RUN conda create -p /fire_danger_tool/env/fireml python=3.10
RUN echo "conda activate /fire_danger_tool/env/fireml" > ~/.bashrc
RUN conda install -c conda-forge mamba
RUN mamba init
RUN mamba install -c conda-forge gdal cython cf-units=3.2.0 esmpy
    WORKDIR /fire_danger_tool/frameworks/geokube/
RUN python setup.py install
WORKDIR /fire_danger_tool
RUN --mount=type=cache,target=/root/.cache/pip \
    --mount=type=bind,source=requirements.txt,target=requirements.txt \
    python -m pip install -r requirements.txt
RUN cp -f /fire_danger_tool/env/fireml/lib/libstdc++.so.6 /usr/lib/aarch64-linux-gnu/libstdc++.so.6
RUN python -c "from geokube.core.datacube import DataCube"
WORKDIR /fire_danger_tool/frameworks/kit4dl/
RUN pip install -e .
WORKDIR /fire_danger_tool
ARG UID=10001
RUN adduser \
    --disabled-password \
    --gecos "" \
    --home "/nonexistent" \
    --shell "/sbin/nologin" \
    --no-create-home \
    --uid "${UID}" \
    appuser

USER appuser

EXPOSE 8000

CMD python src/inference.py --date=2018-08-20 --conf=src/config/inference_config.toml --collect_data --prepare_static
    
    ARG UID=10001
    RUN adduser \
        --disabled-password \
        --gecos "" \
        --home "/nonexistent" \
        --shell "/sbin/nologin" \
        --no-create-home \
        --uid "${UID}" \
        appuser
    
    
    USER appuser
    
    EXPOSE 8000
    
    CMD python src/inference.py --date=2018-08-20 --conf=src/config/inference_config.toml --collect_data --prepare_static

The docker image is created without error. But when I run the docker image, it seems that the conda environment is not already activated in the image. Moreover, conda has not been initiated. I need the conda environment because one of the libraries I need is only available in conda or to be installed from the source. Installing the said library from the source had its own problems.

Is there a way to create a docker image with the conda environment already activated?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.