diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9c7e932 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,17 @@ +# Python-generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info + +# Virtual environments +.venv + +temp/* +outputs +*_cache* + +# Ignore environment and config secrets +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e7d82bb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +# Start from a CUDA-enabled base image with Python +FROM nvidia/cuda:12.6.1-base-ubuntu24.04 + +# Avoid running as root user for security +RUN groupadd -r fullwave && useradd -m -g fullwave fullwave + +# Set working directory +WORKDIR /app + +# Install system dependencies (build essentials, CUDA dev libs, etc.) +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + python3 python3-pip python3-venv \ + git build-essential make curl ca-certificates \ + libgl1-mesa-dev ffmpeg libsm6 libxext6 && \ + rm -rf /var/lib/apt/lists/* + + +# ---- install uv package manager ---- +# Download the latest installer +ADD https://astral.sh/uv/install.sh /uv-installer.sh + +# Run the installer then remove it +RUN sh /uv-installer.sh && rm /uv-installer.sh + +# Ensure the installed binary is on the `PATH` +ENV PATH="/root/.local/bin/:$PATH" +ENV PATH="/app/.venv/bin:$PATH" + +# ---- +# RUN curl -LsSf https://astral.sh/uv/install.sh | sh + +COPY pyproject.toml ./ +COPY uv.lock ./ +COPY Makefile ./ + +# Copy the project into the image +ADD . /app + +# Sync the project into a new environment, asserting the lockfile is up to date +RUN uv sync --all-extras + +# Install Python dependencies efficiently +RUN uv run pre-commit install + +# Set permissions for non-root user +RUN chown -R fullwave:fullwave /app + +# Switch to user, preserve CUDA access +USER fullwave + +# Specify default runtime arguments for simulation (override as needed) +CMD ["/bin/bash", "-c", "source /app/.venv/bin/activate && pytest"] diff --git a/README.md b/README.md index 98898e6..6b2836b 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,36 @@ Please see the following examples for more advanced usage. - Please write clear and concise commit messages. - please see [CONTRIBUTING.md](CONTRIBUTING.md) for more details. +### Dockerfile usage + +- A Dockerfile is provided for easy setup of the Fullwave 2.5 environment. +- To build the Docker image, run the following command in the terminal from the root directory of the repository: + + ```sh + docker build -t fullwave25:latest . + ``` + +- The command below runs pytest to verify the installation inside the Docker container: + + ```sh + docker run --gpus all fullwave25:latest + ``` + +- To run a container from the built image, use the following command: + + ```sh + docker run --gpus all -it --rm --name fullwave_container fullwave25:latest /bin/bash + ``` + +- Inside the container, you can run the example simulations. For instance, to run the simple plane wave example, execute: + + ```sh + source /app/.venv/bin/activate + python3 /app/examples/simple_plane_wave/simple_plane_wave.py + ``` + +- For a persistent container that retains data after exiting, please refer to [Dockerdocs: Persisting container data](https://docs.docker.com/get-started/docker-concepts/running-containers/persisting-container-data/) + --- ## Maintainers diff --git a/uv.lock b/uv.lock index 0913c68..54c108f 100644 --- a/uv.lock +++ b/uv.lock @@ -545,7 +545,7 @@ wheels = [ [[package]] name = "fullwave25" -version = "1.0.7" +version = "1.0.8" source = { editable = "." } dependencies = [ { name = "matplotlib" },