@@ -2,15 +2,28 @@ FROM python:3.11-slim-bookworm
22
33ENV PYTHONUNBUFFERED=1
44
5- WORKDIR /app/
65
6+ ENV SQLBOT_HOME=/opt/sqlbot
7+ ENV APP_HOME=$SQLBOT_HOME/app
8+ ENV UI_HOME=$SQLBOT_HOME/frontend
9+ RUN mkdir -p $APP_HOME
10+ RUN mkdir -p $UI_HOME
11+
12+
13+
14+
15+ WORKDIR $APP_HOME
16+ ENV PYTHONPATH=$APP_HOME
17+
18+ # COPY ../frontend/dist $UI_HOME/dist
19+ COPY ./dist $UI_HOME/dist
720# Install uv
821# Ref: https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
922COPY --from=ghcr.io/astral-sh/uv:0.5.11 /uv /uvx /bin/
1023
1124# Place executables in the environment at the front of the path
1225# Ref: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment
13- ENV PATH="/app /.venv/bin:$PATH"
26+ ENV PATH="$APP_HOME /.venv/bin:$PATH"
1427
1528# Compile bytecode
1629# Ref: https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
@@ -22,26 +35,18 @@ ENV UV_LINK_MODE=copy
2235
2336# Install dependencies
2437# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
25- # RUN --mount=type=cache,target=/root/.cache/uv \
26- # --mount=type=bind,source=uv.lock,target=uv.lock \
27- # --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
28- # uv sync --frozen --no-install-project
29-
30- ENV PYTHONPATH=/app
31-
32- # COPY ./scripts /app/scripts
33-
38+ RUN test -f "./uv.lock" && \
39+ --mount=type=cache,target=/root/.cache/uv \
40+ --mount=type=bind,source=uv.lock,target=uv.lock \
41+ --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
42+ uv sync --frozen --no-install-project || echo "uv.lock file not found, skipping intermediate-layers"
3443
35- # COPY ./pyproject.toml ./uv.lock ./alembic.ini /app/
44+ COPY . $APP_HOME
3645
37- # COPY ./alembic ./apps ./common /app/
38- COPY . /app/
3946
4047# Sync the project
4148# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
4249RUN --mount=type=cache,target=/root/.cache/uv \
43- uv sync
50+ uv sync
4451
4552CMD ["fastapi" , "run" , "--workers" , "4" , "main.py" ]
46- # CMD ["uvicorn", "main:app", "--reload"]
47- # CMD ["python", "main.py", "--reload"]
0 commit comments