Skip to content

Commit

Permalink
Use poetry in Dockerfile, del requirements.txt, improve docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorpela committed Mar 5, 2024
1 parent 208362e commit f35e6f4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@ FROM python:3.11
# Install system dependencies
RUN apt-get update && apt-get install -y libmagic1 && rm -rf /var/lib/apt/lists/*

# Install Poetry
RUN pip install poetry

# Set the working directory
WORKDIR /backend

COPY ./backend .
# Copy only dependencies
COPY ./backend/pyproject.toml ./backend/poetry.lock* ./

RUN rm poetry.lock
# Install dependencies
# --no-dev: Skip installing packages listed in the [tool.poetry.dev-dependencies] section
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi --no-dev

RUN pip install .
# Copy the rest of backend
COPY ./backend .

# Copy the frontend build
COPY --from=builder /frontend/dist ./ui
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ Because this is open source, if you do not like those architectures or want to m

**Install requirements**

The backend service uses [poetry](https://python-poetry.org/docs/#installation) to manage dependencies.
It assumes libmagic to be [installed](https://github.com/ahupp/python-magic?tab=readme-ov-file#installation) in your host system.

```shell
cd backend
pip install -r requirements.txt
poetry install
```

**Set up persistence layer**
Expand Down
14 changes: 11 additions & 3 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ FROM python:3.11
# Install system dependencies
RUN apt-get update && apt-get install -y libmagic1 && rm -rf /var/lib/apt/lists/*

# Install Poetry
RUN pip install poetry

# Set the working directory
WORKDIR /backend

COPY . .
# Copy only dependencies
COPY pyproject.toml poetry.lock* ./

RUN rm poetry.lock
# Install dependencies
# --no-dev: Skip installing packages listed in the [tool.poetry.dev-dependencies] section
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi --no-dev

RUN pip install .
# Copy the rest of application code
COPY . .

ENTRYPOINT [ "uvicorn", "app.server:app", "--host", "0.0.0.0" ]
10 changes: 0 additions & 10 deletions backend/requirements.txt

This file was deleted.

0 comments on commit f35e6f4

Please sign in to comment.