Skip to content

Commit

Permalink
Cleanup docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
gutzbenj committed Feb 16, 2025
1 parent 25e46a7 commit 7cb40cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

### Refactor
- Improve date parsing across multiple apis
- Cleanup docker image

### Fix
- \[WSV Pegel\] Fix characteristic values and improve date parsing
Expand Down
38 changes: 4 additions & 34 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,13 @@
FROM python:3.13-slim-bookworm AS build
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS build

ENV DEBIAN_FRONTEND=noninteractive
ENV TERM=linux

# Install build prerequisites.
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN \
--mount=type=cache,id=apt,sharing=locked,target=/var/cache/apt \
--mount=type=cache,id=apt,sharing=locked,target=/var/lib/apt \
true \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests --yes \
git build-essential python3-dev python3-pip python3-venv python3-wheel \
python3-h5py ca-certificates pkg-config libhdf5-dev

RUN pip install uv

# Install wradlib.
RUN uv pip install --system wradlib

# Install Wetterdienst.

# Use `poetry build --format=wheel` to build wheel packages into `dist` folder.
# Copy wheel that was generated in the previous step (./.github/workflows/docker-publish.yml).
# If you want to build the Docker image locally, you need to build the wheel first e.g. with `uv build`.
COPY dist/wetterdienst-*.whl /tmp/

# Install package.
# Pick latest wheel package from `/tmp` folder.
# Install wetterdienst using latest wheel package from `/tmp` folder.
RUN --mount=type=cache,id=pip,target=/root/.cache/pip \
true \
&& WHEEL=$(ls -r /tmp/wetterdienst-*-py3-none-any.whl | head -n 1) \
&& uv pip install --system versioningit \
&& uv pip install --system ${WHEEL}[bufr,cratedb,duckdb,explorer,influxdb,interpolation,plotting,postgresql,radar,radarplus,restapi]

# TODO: for linux/arm64 we currently cant install zarr as it depends on numcodecs which has no wheels
Expand All @@ -42,17 +20,9 @@ RUN WHEEL=$(ls -r /tmp/wetterdienst-*-py3-none-any.whl | head -n 1) && \
uv pip install --system ${WHEEL}[export_without_zarr]; \
fi


# Final stage
FROM python:3.13-slim-bookworm

# Install h5py
RUN apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests --yes \
python3-h5py \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Copy installed pip packages from build stage
COPY --from=build /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages
COPY --from=build /usr/local/bin /usr/local/bin

0 comments on commit 7cb40cf

Please sign in to comment.