Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
FROM ubuntu:22.04

# Install build tools, ForeFire dependencies, AND Python environment
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libnetcdf-c++4-dev \
cmake
cmake \
python3 \
python3-pip \
python3-dev \
git && \
rm -rf /var/lib/apt/lists/*

WORKDIR /forefire
ENV FOREFIREHOME=/forefire

# we could only copy src, cmakelists.txt and cmake-build.sh
COPY . .

# install forefire
# Build and install the ForeFire C++ library
RUN sh cmake-build.sh

# add executable to PATH
RUN cp /forefire/bin/forefire /bin
# Add the main forefire executable to the PATH
RUN cp /forefire/bin/forefire /usr/local/bin/

# Use pip to install the Python dependencies defined in pyproject.toml
RUN pip3 install ./bindings/python

# Set the entrypoint to bash for interactive sessions
CMD ["bash"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The easiest way to get started is often using Docker and the interactive console
3. Run the container interactively

```bash
docker run -it --rm -p 8000:8000 --name ff_interactive forefire bash
docker run -it --rm -p 8000:8000 --name ff_interactive forefire
```
4. Inside the container navigate to test directory and launch the forefire console:
```bash
Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting_started/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Steps

.. code-block:: bash

docker run -it --rm -p 8000:8000 --name ff_interactive forefire bash
docker run -it --rm -p 8000:8000 --name ff_interactive forefire

4. **Inside the container, navigate to the test directory:**

Expand Down
22 changes: 22 additions & 0 deletions tools/docker/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ubuntu:22.04

RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libnetcdf-c++4-dev \
cmake

WORKDIR /forefire
ENV FOREFIREHOME=/forefire

# we could only copy src, cmakelists.txt and cmake-build.sh
COPY . .

# install forefire
RUN sh cmake-build.sh

# add executable to PATH
RUN cp /forefire/bin/forefire /usr/local/bin/

# Set the entrypoint to bash for interactive sessions
CMD ["bash"]
60 changes: 60 additions & 0 deletions tools/docker/Dockerfile.multistage
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# File: tools/Dockerfile.multistage
# Target: Creates an optimized, smaller final image using a multi-stage build.
# Contains full Python support.

# --- STAGE 1: The "Builder" ---
# This stage is a temporary environment used to compile the C++ code.
# It contains all the heavy build tools, which will NOT be in the final image.
FROM ubuntu:22.04 AS builder

# Install build tools and C++ dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libnetcdf-c++4-dev \
cmake \
git && \
rm -rf /var/lib/apt/lists/*

WORKDIR /src

# Copy all source code into the builder stage
COPY . .

# Build the C++ library and executable
RUN sh cmake-build.sh


# --- STAGE 2: The "Final Image" ---
# This is the final, clean image that will be distributed.
# It starts from a fresh Ubuntu base and only pulls in what's necessary.
FROM ubuntu:22.04

# Install only the RUNTIME dependencies needed for ForeFire and the Python bindings.
# As requested, we use libnetcdf-c++4-dev here for consistency with the build stage.
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libnetcdf-c++4-dev \
libgomp1 \
python3 \
g++ \
python3-pip \
python3-dev && \
rm -rf /var/lib/apt/lists/*

WORKDIR /forefire
ENV FOREFIREHOME=/forefire

# The magic step: Copy the ENTIRE built project from the 'builder' stage.
# This brings over the compiled libs, binaries, and the source code needed for the bindings.
COPY --from=builder /src/ .

# Add the forefire executable to the system's PATH
RUN cp /forefire/bin/forefire /usr/local/bin/

# Install the Python bindings and their dependencies (numpy, etc.)
# This compiles the C++ extension using the headers we just copied.
RUN pip3 install ./bindings/python

# Set the default command to start a bash shell
CMD ["bash"]
10 changes: 10 additions & 0 deletions tools/docker/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Alternative Dockerfiles

WIP

- Dockerfile without python to make the image smaller
- Multistage build to make the also smaller (490 vs 620 mb)

```
docker build -f tools/docker/Dockerfile.multistage -t forefire:multistage .
```
Loading