Skip to content

Instantly share code, notes, and snippets.

@ZappaBoy
Last active March 18, 2023 16:08
Show Gist options
  • Save ZappaBoy/226189694137df80afd0332312b5e2fb to your computer and use it in GitHub Desktop.
Save ZappaBoy/226189694137df80afd0332312b5e2fb to your computer and use it in GitHub Desktop.
Dockerfile gdal latest version with conda - FastAPI, uvicorn and Python 3.11
# You can change the base image if you don't need FastAPI or Uvicorn
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.11-slim
WORKDIR /app
RUN apt update
RUN apt install -y libpq-dev build-essential wget
ENV CONDA_DIR /opt/conda
RUN wget -nv https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
bash ~/miniconda.sh -b -p "$CONDA_DIR" && \
rm ~/miniconda.sh && \
"$CONDA_DIR/bin/conda" clean -tip && \
ln -s "$CONDA_DIR/etc/profile.d/conda.sh" /etc/profile.d/conda.sh && \
echo ". $CONDA_DIR/etc/profile.d/conda.sh" >> ~/.bashrc && \
echo "conda activate base" >> ~/.bashrc
ENV PATH /opt/conda/bin:$PATH
RUN conda create -n gdalenv
SHELL ["conda", "run", "-n", "gdalenv", "/bin/bash", "-c"]
RUN conda config --add channels conda-forge
RUN conda install -y gdal
COPY requirements.txt .
RUN pip install -r requirements.txt --ignore-installed gdal
COPY ./app .
EXPOSE 80
# Change the entrypoint.sh with python if you don't use a script to start your application
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "gdalenv", "/bin/bash", "entrypoint.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment