Skip to content

Commit

Permalink
fix docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
hrodmn committed Dec 19, 2024
1 parent 4188425 commit 647c276
Show file tree
Hide file tree
Showing 3 changed files with 248 additions and 43 deletions.
47 changes: 30 additions & 17 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,62 @@ 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-overture-maps
COPY --from=base /opt/conda /opt/conda
COPY pyproject.toml ./
COPY src/stactools/overture_maps/__init__.py src/stactools/overture_maps/
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/overture_maps
&& 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-overture-maps
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-overture-maps
CMD [ "stac", "overturemaps" ]
CMD [ "stac", "overturemapscmd" ]


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-overture-maps
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
Expand All @@ -54,4 +67,4 @@ WORKDIR /opt/stactools-overture-maps
COPY --from=base /opt/conda /opt/conda
COPY --from=dependencies /opt/venv /opt/venv
COPY . .
CMD [ "stac", "overturemaps" ]
CMD [ "stac", "overturemapscmd" ]
5 changes: 3 additions & 2 deletions docker/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
--target dev-builder \
.
docker run --rm \
--entrypoint scripts/cibuild \
stactools-packages/overture-maps:dev
--entrypoint uv \
stactools-packages/overture-maps:dev \
sync
fi
Loading

0 comments on commit 647c276

Please sign in to comment.