Created
September 2, 2021 04:18
-
-
Save joshatxantie/4bcf5d0243fba63845fce7cc40365a3a to your computer and use it in GitHub Desktop.
Dockerize Pyodbc/SQL Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# syntax=docker/dockerfile:1 | |
FROM python:3.8-slim-buster | |
WORKDIR /app | |
ENV ACCEPT_EULA=Y | |
RUN apt-get update -y && apt-get update \ | |
&& apt-get install -y --no-install-recommends curl gcc g++ gnupg unixodbc-dev | |
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \ | |
&& curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list \ | |
&& apt-get update \ | |
&& apt-get install -y --no-install-recommends --allow-unauthenticated msodbcsql17 mssql-tools \ | |
&& echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile \ | |
&& echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc | |
COPY requirements.txt requirements.txt | |
RUN pip3 install -r requirements.txt | |
COPY . . | |
CMD [ "python3", "main.py" ] |
I hope this helps someone. Took me forever to figure this out.
This worked! I can't thank you enough man.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
THANK YOU! This not only worked for me, but made very good sense.
I'd like to add that I was creating a FastAPI REST API, and the server part of my pyodbc connection string was confusing to me.
Then I found that ...
Per The StackOverflow