Help with Dockerfile to enable ODBC drivers for app hosted on Render from Private git repo

I have a functioning app hosted on Render from a private git repo. I’d like to add a feature that requires accessing a SQL db, which means I need pyODBC. Render doesn’t install drivers for SQL out of the box, which means I need to build an image via a dockerfile for my deployment.

Here is my current Dockerfile, I don’t know what I’m doing… please help. I believe my current limitation is that I need a SSH key to clone my private git repo for the build to continue.

(i’d like to include tesseract installs to this in the future, hence the commented out ocr packages. Problem for another day…)

# https://docs.streamlit.io/knowledge-base/tutorials/deploy/docker

FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2
COPY vc_redist.x64.exe c:/ \
     msodbcsql_17.3.1.1_x64.msi c:/
RUN c:\\vc_redist.x64.exe /install /passive /norestart 
RUN msiexec.exe /i C:\\msodbcsql_17.3.1.1_x64.msi /norestart /qn /quiet /passive IACCEPTMSODBCSQLLICENSETERMS=YES 

# Use an official PHP runtime as a parent image https://hub.docker.com/_/python
FROM python:3.9-slim-buster

# Set the working directory in the container
WORKDIR /app

# apt-get -qq -y install tesseract-ocr && \
# apt-get -qq -y install libtesseract-dev \
# Install required system packages and dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    software-properties-common \
    git \
    && rm -rf /var/lib/apt/lists/*

# $ docker run --privileged --rm tonistiigi/binfmt --install all

RUN git clone https://github.com/private/app.git .

RUN pip3 install -r requirements.txt

COPY . .

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]

# mkdir .streamlit; cp /etc/secrets/secrets.toml ./.streamlit/; pip install --upgrade pip &&  pip install -r requirements.txt

I’m sure I don’t need some command lines in there, and may need to add others. I’m also not 100% attached to Render.com, I was looking at moving hosting to Digital-Ocean if that would make things easier…

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.