Poetry: Dockfile example using poetry?

Created on 1 Feb 2019  路  2Comments  路  Source: python-poetry/poetry

I want to dockerize my app but I am getting issues related to paths and stuff.

Most helpful comment

Did you find examples? If yes, could you share them? Others could find this useful.

I myself used Poetry in a Dockerfile like so:

FROM python:3.6
RUN mkdir /app
WORKDIR /app

RUN pip install poetry
RUN poetry config settings.virtualenvs.create false
COPY poetry.lock pyproject.toml README.md /app/

# to prevent poetry from installing my actual app,
# and keep docker able to cache layers
RUN mkdir -p /app/src/app
RUN touch /app/src/app/__init__.py

RUN poetry install -n

# now actually copy the real contents of my app
COPY app /app/src/app

EXPOSE 8000
CMD ["gunicorn", "-c", "docker/services/gunicorn/conf.py", "--bind", ":8000", "--chdir", "src/app", "core.wsgi:application"]

All 2 comments

Did you find examples? If yes, could you share them? Others could find this useful.

I myself used Poetry in a Dockerfile like so:

FROM python:3.6
RUN mkdir /app
WORKDIR /app

RUN pip install poetry
RUN poetry config settings.virtualenvs.create false
COPY poetry.lock pyproject.toml README.md /app/

# to prevent poetry from installing my actual app,
# and keep docker able to cache layers
RUN mkdir -p /app/src/app
RUN touch /app/src/app/__init__.py

RUN poetry install -n

# now actually copy the real contents of my app
COPY app /app/src/app

EXPOSE 8000
CMD ["gunicorn", "-c", "docker/services/gunicorn/conf.py", "--bind", ":8000", "--chdir", "src/app", "core.wsgi:application"]

```Dockerfile
FROM python:3.7.2
COPY . /app
WORKDIR /app
RUN curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
RUN /root/.poetry/bin/poetry install
CMD ["/root/.poetry/bin/poetry", "run", "python", "./start.py"]
````
my docker file

Was this page helpful?
0 / 5 - 0 ratings