Last active
June 20, 2024 10:59
-
-
Save sairamkrish/4325a28f66be125c3aa4d68a950950cb to your computer and use it in GitHub Desktop.
Python | Poetry | Dockerfile and private repositories. Details - https://sairamkrish.medium.com/python-poetry-dockerfile-and-private-repositories-1b1108af3c6
This file contains 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
# gather requirements | |
FROM python:3.9.2-slim as requirements-stage | |
WORKDIR /tmp | |
COPY ./pyproject.toml ./poetry.lock /tmp/ | |
RUN apt-get update && \ | |
apt-get install -y git && \ | |
pip install poetry && \ | |
poetry export -f requirements.txt --output requirements.txt --without-hashes | |
# Final stage | |
FROM apache/spark-py:v3.3.0 | |
ARG spark_uid=185 | |
ARG private_repo_username | |
ARG private_repo_token | |
USER ${spark_uid} | |
WORKDIR /app | |
COPY --from=requirements-stage /tmp/requirements.txt . | |
RUN git config --global credential.helper store && \ | |
echo "@gitlab.com">https://${private_repo_username}:${private_repo_token}@gitlab.com" > ${HOME}/.git-credentials && \ | |
pip install --no-cache-dir --upgrade -r /app/requirements.txt && \ | |
rm -rf ${HOME}/.git-credentials | |
COPY . . | |
CMD ["python", "app.main:app"] |
@sairamkrish Looks like there is typo in line 19
should be
echo "https://${private_repo_username}:${private_repo_token}@gitlab.com" > ${HOME}/.git-credentials && \
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When we have an ecosystem like python — poetry — dockerfile and private repositories, there are few areas that will cause issues. Here are my notes while solving such issues.
Issue and solution is explained in this blog - https://sairamkrish.medium.com/python-poetry-dockerfile-and-private-repositories-1b1108af3c6