1- FROM ubuntu:jammy
1+ FROM ghcr.io/astral-sh/uv:python3.13-trixie AS build
22
33# Once this image is built:
44# If you have a script $HOME/tmp/foo.py,
55# you can run it via
6- # docker run --rm -v $HOME/tmp:/app fwdpy11 python3 /app/foo.py
6+ # docker run --rm -v $HOME/tmp:/work:z fwdpy11 sh -c ". /app/venv/bin activate && python3 /work/ foo.py"
77WORKDIR /app
88
99COPY . /app
10+ ENV PATH /root/.cargo/bin:$PATH
1011
1112RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
12- gcc \
13- git \
14- g++ \
1513 libgsl-dev \
16- python3 \
17- python3-dev \
18- python3-venv \
19- python3-pip \
20- curl \
2114 && rm -rf /var/lib/apt/lists/* \
22- && rm -rf build \
15+ && rm -rf build dist \
16+ # For some reason, installing rustup with apt and then setting the toolchain
17+ # results in Corrosion being unable to find a valid toolchain.
18+ # We should try to fix this later.
2319 && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y \
2420 && . "$HOME/.cargo/env" \
2521 # Pin the rustc toolchain to a specific version.
@@ -31,19 +27,13 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
3127 && cargo install --locked cbindgen@0.24.3 \
3228 && rustc --version \
3329 && cbindgen --version \
34- && ls -lhrt
30+ && uv build . \
31+ && uv venv /app/venv \
32+ && . /app/venv/bin/activate \
33+ && ls -lhrt dist \
34+ && uv pip install dist/fwdpy11*.whl
3535
36- RUN . "$HOME/.cargo/env" \
37- && python3 -m venv venv \
38- && . venv/bin/activate \
39- && python -m pip install --upgrade pip \
40- && python -m pip install build \
41- && python -m build . \
42- && deactivate \
43- && python3 -m pip install dist/fwdpy11*.whl \
44- && rm -rf venv \
45- && python3 -m venv /venv \
46- && . /venv/bin/activate \
47- && python3 -m pip install dist/fwdpy11*.whl \
48- && cd / \
49- && rm -rf /app /root/.cargo
36+ FROM python:3.13-slim-trixie
37+ COPY --from=build /app/venv /app/venv
38+ # Make sure the GSL runtime is present
39+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install libgsl28 && apt clean
0 commit comments