@@ -8,6 +8,7 @@ ARG USER=lightman
88ARG GROUP=lightman
99ARG WORKDIR=/app
1010ARG VENV_PATH=${WORKDIR}/.venv
11+ ARG BIN_PATH=${VENV_PATH}/bin
1112
1213WORKDIR ${WORKDIR}
1314
@@ -19,52 +20,46 @@ RUN groupadd -g 1001 ${GROUP} && \
1920FROM base AS build
2021
2122# Define stage variables
22- ARG POETRY_VERSION=2.1.2
23- ARG POETRY_PLUGIN_EXPORT_VERSION=1.9.0
24-
25- # These should never change, define as ENV
26- ENV POETRY_HOME="/opt/poetry"
27- ENV PATH="${POETRY_HOME}/bin:${PATH}"
28-
29- # Create venv and upgrade pip
30- RUN python -m venv ${VENV_PATH} && \
31- ${VENV_PATH}/bin/pip install --no-cache-dir --upgrade pip
32-
23+ ARG UV_VERSION 0.8.0
24+ # Install curl for uv installation
3325RUN apt-get update && apt-get install -y --no-install-recommends \
3426 curl \
3527 && rm -rf /var/lib/apt/lists/*
3628
37- RUN pip install poetry==2.1.2
38- RUN poetry self add poetry-plugin-export==${POETRY_PLUGIN_EXPORT_VERSION}
29+ ADD https://astral.sh/uv/install.sh /uv-installer.sh
3930
40- # Copy all the needed files, without write permissions
41- COPY poetry.lock pyproject.toml ./
31+ # Run the installer then remove it
32+ RUN curl -LsSf https://astral.sh/uv/${UV_VERSION}/install.sh | sh
4233
43- # Export dependencies to requirements.txt (no dev deps)
44- RUN poetry export --without-hashes --only main -f requirements.txt > requirements.txt
34+ # Ensure the installed binary is on the `PATH`
35+ ENV PATH= "/root/.local/bin/:$PATH"
4536
46- # Create and install dependencies in the virtual env
47- RUN ${VENV_PATH}/bin/pip install --no-cache-dir -r requirements.txt
37+ # Copy dependency files
38+ COPY uv.lock pyproject.toml ./
4839
40+ # Install dependencies using uv (only dependencies, not the project itself)
41+ RUN UV_PROJECT_ENVIRONMENT=${VENV_PATH} uv sync --frozen --no-install-project
42+ RUN ${BIN_PATH}/python -m ensurepip
4943# --------------- `final` stage ---------------
5044FROM base AS final
5145
5246# Set non-root user and group
5347USER ${USER}:${GROUP}
5448
55- # Copy over the virtual environment with all its dependencies and the project installed
56- COPY --from=build ${WORKDIR}/requirements.txt requirements.txt
57- ENV PATH="${VENV_PATH}/bin:$PATH"
58-
59- # Copy venv with all its dependencies along with pyproject.toml
49+ # Copy the virtual environment from build stage
6050COPY --from=build --chown=${USER}:${GROUP} ${VENV_PATH} ${VENV_PATH}
51+
52+ # Set PATH to use the virtual environment
53+ ENV PATH="${BIN_PATH}:$PATH"
54+
55+ # Copy pyproject.toml for package metadata
6156COPY --from=build --chown=${USER}:${GROUP} ${WORKDIR}/pyproject.toml .
6257
6358COPY README.md README.md
6459# Copy source code
6560COPY src src
6661
67- # Install the CLI tool
68- RUN $VENV_PATH/bin/pip install --no-cache-dir .
62+ # Install the CLI tool (dependencies already installed in venv)
63+ RUN ${BIN_PATH}/pip3 install --no-deps .
6964
70- ENTRYPOINT [ "lightman" ]
65+ ENTRYPOINT [ "lightman-ai " ]
0 commit comments