I’m trying to deploy a django application on heroku. I use docker and poetry. I have a problem because in the dockerfile I install poetry and install dependencies using poetry. Locally it works fine, but when I want to deploy on heroku, the dependencies are not installed. Only putting code like:
‘RUN pip install -r requirements.txt’ installs the dependencies on heroku (I created the requirements.txt file using poetry export).
Should I have two different Dockerfiles for dev and prod, where I will use poetry in one and pip install requirements in the other ? Or should I use multistaged Dockerfile or do you have any other suggestions ?
My Dockerfile with potery:
FROM python:3.11-alpine
WORKDIR /code
ENV PYTHONUNBUFFERED 1
ENV PATH "/root/.local/bin:$PATH"
RUN apk add --no-cache curl
&& curl -sSL https://install.python-poetry.org | python3 -
&& apk add --no-cache postgresql-dev musl-dev
COPY poetry.lock pyproject.toml /code/
RUN poetry install --no-root
COPY . /code/
RUN poetry install
heroku.yml:
build:
docker:
web: backend/Dockerfile
run:
web: gunicorn core.wsgi:application --bind 0.0.0.0:$PORT
tomtom is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.