Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions Dockerfile.api
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
FROM python:3.11

WORKDIR /sqlmesh

FROM python:3.11-slim-bullseye AS venv-image
RUN apt-get update && apt-get -y install libpq-dev gcc
COPY setup.py setup.py
COPY sqlmesh/_version.py sqlmesh/_version.py
ENV VIRTUAL_ENV=/.venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN python3 -m venv $VIRTUAL_ENV
RUN pip3 install -e .[dev,web]

RUN pip install -e .[dev,web]
FROM python:3.11-slim-bullseye as app-image
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you referencing python 3.11 both times? can you explain a bit about what this pr is doing?

Copy link
Copy Markdown
Author

@singulart singulart May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Dockerfile was updated the following way:

  1. The "slimmer" base image python:3.11-slim-bullseye was used.
  2. Multi-stage build approach was used: https://docs.docker.com/build/building/multi-stage

The 2) is why the image is being referenced twice. Hope that helps! Let me know if you need more clarity on this ;)

WORKDIR /app
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN python3 -m venv $VIRTUAL_ENV
COPY --from=venv-image /.venv $VIRTUAL_ENV
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
build:
context: .
dockerfile: Dockerfile.api
command: python web/server/openapi.py
command: python3 web/server/openapi.py
volumes:
- .:/sqlmesh

Expand Down Expand Up @@ -37,7 +37,7 @@ services:
build:
context: .
dockerfile: Dockerfile.api
command: python -m uvicorn web.server.main:app --host 0.0.0.0 --port 8000 --reload --reload-dir /sqlmesh/web/server --reload-dir /sqlmesh/sqlmesh --timeout-keep-alive 300 --timeout-graceful-shutdown 1
command: python3 -m uvicorn web.server.main:app --host 0.0.0.0 --port 8000 --reload --reload-dir /sqlmesh/web/server --reload-dir /sqlmesh/sqlmesh --timeout-keep-alive 300 --timeout-graceful-shutdown 1
ports:
- 8000:8000
volumes:
Expand Down