| 1 |
# docker buildx build --push --platform linux/amd64,linux/arm64/v8 -o type=image -t briansimulator/brian -f docker/Dockerfile . |
| 2 |
# docker run -it --init --rm -p 8888:8888 briansimulator/brian |
| 3 |
|
| 4 |
ARG BASE_IMAGE_TAG=3.12-slim-bookworm |
| 5 |
FROM python:${BASE_IMAGE_TAG} |
| 6 |
|
| 7 |
LABEL maintainer="Ben Evans <[email protected]>" \ |
| 8 |
org.opencontainers.image.vendor="The Brian Development Team" \ |
| 9 |
org.opencontainers.image.licenses="CeCILL 2.1" \ |
| 10 |
org.opencontainers.image.title="Brian Docker Image" \ |
| 11 |
org.opencontainers.image.description="Docker image for Brian - a free, open source simulator for spiking neural networks" \ |
| 12 |
org.opencontainers.image.homepage="https://briansimulator.org" \ |
| 13 |
org.opencontainers.image.url="https://hub.docker.com/r/briansimulator/brian" \ |
| 14 |
org.opencontainers.image.source="https://github.com/brian-team/brian2" \ |
| 15 |
org.opencontainers.image.documentation="https://brian2.readthedocs.io/" |
| 16 |
|
| 17 |
# Install dependencies |
| 18 |
RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 19 |
build-essential \ |
| 20 |
g++ \ |
| 21 |
git \ |
| 22 |
libgsl-dev \ |
| 23 |
sudo \ |
| 24 |
&& rm -rf /var/lib/apt/lists/* |
| 25 |
|
| 26 |
# Create a non-root user (password same as username) |
| 27 |
ARG USER="monty" |
| 28 |
RUN groupadd ${USER} && \ |
| 29 |
useradd -ms /bin/bash -g ${USER} -G sudo ${USER} && \ |
| 30 |
echo "${USER}:${USER}" | chpasswd |
| 31 |
ENV HOME="/home/${USER}" |
| 32 |
RUN chown -R ${USER}:${USER} ${HOME} |
| 33 |
|
| 34 |
# Install Recommended packages |
| 35 |
RUN python -m pip install --no-cache-dir --only-binary=:all: \ |
| 36 |
scipy \ |
| 37 |
matplotlib \ |
| 38 |
jupyterlab \ |
| 39 |
pytest \ |
| 40 |
pytest-xdist |
| 41 |
|
| 42 |
# Copy wheels into the image |
| 43 |
COPY dist /tmp/dist |
| 44 |
|
| 45 |
# Install Brian2 |
| 46 |
RUN python -m pip install /tmp/dist/[Bb]rian2*_$(uname -m).whl brian2tools \ |
| 47 |
&& rm -rf /tmp/dist |
| 48 |
|
| 49 |
USER ${USER} |
| 50 |
|
| 51 |
# Copy tutorial notebooks and example scripts to home directory |
| 52 |
WORKDIR ${HOME} |
| 53 |
RUN git clone https://github.com/brian-team/brian2.git \ |
| 54 |
&& mv brian2/examples examples \ |
| 55 |
&& mv brian2/tutorials tutorials \ |
| 56 |
&& chmod -R +x tutorials \ |
| 57 |
&& chmod -R +x examples \ |
| 58 |
&& find . -name '*.ipynb' -exec jupyter trust {} \; \ |
| 59 |
&& rm -rf brian2 |
| 60 |
|
| 61 |
EXPOSE 8888 |
| 62 |
CMD ["jupyter", "lab", "--ip=0.0.0.0", "--no-browser"] |