diff --git a/docker/Dockerfile b/docker/Dockerfile index 96f983b..1d378ed 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,36 +2,44 @@ FROM continuumio/miniconda3 as base COPY environment.yml ./ RUN conda update conda && \ - conda env update -f environment.yml -n base && \ - conda clean -af + conda env update -f environment.yml -n base && \ + conda clean -af FROM base as dependencies -ENV PATH="/opt/venv/bin:$PATH" +COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv + +ENV UV_LINK_MODE=copy \ + UV_COMPILE_BYTECODE=1 \ + UV_PYTHON_DOWNLOADS=never \ + UV_PYTHON=python3.12 \ + UV_PROJECT_ENVIRONMENT=/opt/venv \ + PATH="/opt/venv/bin:$PATH" WORKDIR /opt/stactools-ephemeral COPY --from=base /opt/conda /opt/conda COPY pyproject.toml ./ COPY src/stactools/ephemeral/__init__.py src/stactools/ephemeral/ RUN apt-get -y -q update \ - && apt-get -y -q install build-essential \ - && rm -rf /var/lib/apt/lists/ -RUN python -m venv /opt/venv -RUN pip install . \ - && ls /opt/venv \ - && rm -r /opt/venv/lib/python3.12/site-packages/stactools/ephemeral + && apt-get -y -q install build-essential \ + && rm -rf /var/lib/apt/lists/ +RUN uv sync --no-install-project --no-editable FROM dependencies as builder -ENV PATH="/opt/venv/bin:$PATH" +ENV UV_LINK_MODE=copy \ + UV_COMPILE_BYTECODE=1 \ + UV_PYTHON_DOWNLOADS=never \ + UV_PYTHON=python3.12 \ + UV_PROJECT_ENVIRONMENT=/opt/venv \ + PATH="/opt/venv/bin:$PATH" WORKDIR /opt/stactools-ephemeral COPY --from=base /opt/conda /opt/conda COPY --from=dependencies /opt/venv /opt/venv COPY pyproject.toml ./ COPY src ./src -RUN pip install -U pip \ - && pip install . +RUN uv sync --no-dev --no-editable WORKDIR / RUN rm -rf /opt/stactools-ephemeral CMD [ "stac", "ephemeralcmd" ] @@ -39,12 +47,17 @@ CMD [ "stac", "ephemeralcmd" ] FROM dependencies as dev-dependencies -ENV PATH="/opt/venv/bin:$PATH" +ENV UV_LINK_MODE=copy \ + UV_COMPILE_BYTECODE=1 \ + UV_PYTHON_DOWNLOADS=never \ + UV_PYTHON=python3.12 \ + UV_PROJECT_ENVIRONMENT=/opt/venv \ + PATH="/opt/venv/bin:$PATH" WORKDIR /opt/stactools-ephemeral COPY --from=dependencies /opt/venv /opt/venv COPY pyproject.toml . -RUN pip install -e '.[dev]' \ - && git init +RUN uv sync \ + && git init FROM dev-dependencies as dev-builder diff --git a/docker/cibuild b/docker/cibuild index 96c6e68..613b6a4 100755 --- a/docker/cibuild +++ b/docker/cibuild @@ -20,6 +20,7 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then --target dev-builder \ . docker run --rm \ - --entrypoint scripts/cibuild \ - stactools-packages/ephemeral:dev + --entrypoint uv \ + stactools-packages/ephemeral:dev \ + sync fi