# CUDA-enabled multi-stage build to compile and run the project from source
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install required build tools
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential && \
rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
# Copy the repository
COPY . .
# Build the project using the Linux makefile for the CUDA MD example
RUN make -f src/13-md/cpp/makefile ljmd
# Runtime stage
FROM nvidia/cuda:11.8.0-runtime-ubuntu22.04
# Copy the built binary from the builder stage
COPY --from=builder /workspace/ljmd /usr/local/bin/ljmd
# Ensure the CUDA runtime libraries are visible at runtime
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
WORKDIR /workspace
CMD ["bash","-lc","/usr/local/bin/ljmd"]
# Exclude VCS and unnecessary files from the Docker build .git/ .gitignore node_modules/ build/ dist/ __pycache__/ *.pyc *.pyo *.swp *.log *.tmp *.out *.o *.a *.so *.dll *.exe *.cu.d *.cpp.d coverage/ plots/ *.eps *.pdf *.jpg *.png .DS_Store
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
# syntax=docker/dockerfile:1
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 AS builder
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential ca-certificates curl git
# Clean up apt lists to keep image small
RUN rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
# Copy Linux CUDA variant sources (cpp) into the build context
COPY src/13-md/cpp /workspace/src/13-md/cpp
# Build using the Linux Makefile located at src/13-md/cpp/makefile
RUN make -C src/13-md/cpp -f makefile
# Move the resulting binary to a predictable location
RUN mkdir -p /workspace && cp /workspace/src/13-md/cpp/ljmd /workspace/ljmd
# Runtime stage: use a CUDA runtime image
FROM nvidia/cuda:11.8.0-runtime-ubuntu22.04
# Copy the built binary from the builder stage
COPY --from=builder /workspace/ljmd /usr/local/bin/ljmd
WORKDIR /workspace
ENTRYPOINT ["ljmd"]
# Ignore VCS .git .gitignore # IDEs & editors .vscode/ .idea/ # OS files .DS_Store # Build artefacts **/*.o **/*.obj **/*.dll **/*.so **/*.a **/*.out **/*.log build/ dist/ **/__pycache__/ __pycache__/ # Node node_modules/ # CUDA/Build leftovers src/**/build/
# Ignore VCS .git .gitignore # IDEs & editors .vscode/ .idea/ # OS files .DS_Store # Build artefacts **/*.o **/*.obj **/*.dll **/*.so **/*.a **/*.out **/*.log build/ dist/ **/__pycache__/ __pycache__/ # Node node_modules/ # CUDA/Build leftovers src/**/build/
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock
FROM ubuntu:jammy-20260210.1
# Install essential build tools and CUDA toolkit for nvcc
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential ca-certificates wget ca-certificates curl unzip \
&& rm -rf /var/lib/apt/lists/*
# Install CUDA toolkit so nvcc is available for building CUDA sources
RUN apt-get update && apt-get install -y --no-install-recommends \
nvidia-cuda-toolkit \
&& rm -rf /var/lib/apt/lists/*
# Set work directory and copy the repository
WORKDIR /workspace
COPY . /workspace
# Build the project from source using the Linux makefile located at src/13-md/cpp/makefile
RUN make -f src/13-md/cpp/makefile ljmd
# Default command runs the built executable
CMD ["./ljmd"]
# Ignore version control and IDE files .git/ .gitignore .vscode/ .idea/ *.swp *.o *.obj *.dll *.exe *.so build/ out/ **/node_modules/
ERROR: permission denied while trying to connect to the docker API at unix:///var/run/docker.sock