-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically build docker images for each Brian release #1503
Merged
Merged
Changes from 18 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
05c75d1
Initial commit
bdevans e038100
Tidy up
bdevans 55ace74
Add README with instructions
bdevans 40eeebe
Fix sudo
bdevans 7da7e7a
Remove unnecessary use of `buildx`
bdevans cde781f
Update instructions
bdevans bb3e4e4
Rename
bdevans 124304e
Update to use slim image and tidy comments
bdevans 1d2409c
Add test instructions
bdevans 43ce0a5
Merge remote-tracking branch 'refs/remotes/origin/docker_images' into…
bdevans 5b56339
Add docker pulls badge
bdevans d0e94c5
Move docker image action into release
mstimberg 2a15a55
Rename publish action
mstimberg 9e93193
Add publish status badge
bdevans 50ac8ce
Merge remote-tracking branch 'refs/remotes/origin/docker_images' into…
bdevans 50db33d
Use local wheels in docker build
mstimberg 85d1bb6
Only push tags to docker hub
mstimberg b224f62
Fix use of download-artifact action
mstimberg fb78e25
Use recommended invocation of pip
bdevans 7051fea
Use compatible download/upload actions
mstimberg b3f9562
Remove deployment environment (for now)
mstimberg 15f8870
Separate package names for upload-artifact@v4
mstimberg 93bbd60
Even more distinct package names for artifacts
mstimberg 873d355
download with correct package names
mstimberg 9b7f966
Only use manylinux wheels
mstimberg 9c7f64b
Fix expression syntax
mstimberg 43eb956
Misunderstood how the new pattern/merge feature was supposed to work …
mstimberg 4b6962b
Upload docker image as artifact
mstimberg 244d0cc
Cannot use load for multi-arch image, trying again
mstimberg 86a863b
Push docker image to brian-dev repository
mstimberg 67d0242
Document docker build process
mstimberg f437aa6
Fix formatting for multi-line command
mstimberg 84b2ad8
Use uname -m for architecture
mstimberg 77c7263
Install libgsl-dev for GSL support
mstimberg 6f8a3d8
Rearrange
bdevans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# docker buildx build --push --platform linux/amd64,linux/arm64/v8 -o type=image -t briansimulator/brian -f docker/Dockerfile . | ||
# docker run -it --init --rm -p 8888:8888 briansimulator/brian | ||
|
||
ARG BASE_IMAGE_TAG=3.12-slim-bookworm | ||
FROM python:${BASE_IMAGE_TAG} | ||
|
||
LABEL maintainer="Ben Evans <[email protected]>" \ | ||
org.opencontainers.image.vendor="The Brian Development Team" \ | ||
org.opencontainers.image.licenses="CeCILL 2.1" \ | ||
org.opencontainers.image.title="Brian Docker Image" \ | ||
org.opencontainers.image.description="Docker image for Brian - a free, open source simulator for spiking neural networks" \ | ||
org.opencontainers.image.homepage="https://briansimulator.org" \ | ||
org.opencontainers.image.url="https://hub.docker.com/r/briansimulator/brian" \ | ||
org.opencontainers.image.source="https://github.com/brian-team/brian2" \ | ||
org.opencontainers.image.documentation="https://brian2.readthedocs.io/" | ||
|
||
# Install dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
g++ \ | ||
git \ | ||
sudo \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy wheels into the image | ||
COPY dist /tmp/dist | ||
|
||
# Install Brian2 and recommended packages | ||
ARG TARGETARCH | ||
RUN pip install --no-cache-dir --only-binary=:all: \ | ||
scipy \ | ||
matplotlib \ | ||
jupyterlab \ | ||
pytest \ | ||
pytest-xdist \ | ||
&& if [ "${TARGETARCH}" = "arm64" ]; then WHEEL_ARCH=aarch64; else WHEEL_ARCH=x86_64; fi \ | ||
&& pip install /tmp/dist/Brian2*_${WHEEL_ARCH}.whl brian2tools \ | ||
&& rm -rf /tmp/dist | ||
|
||
# Create a non-root user | ||
ARG USER="monty" \ | ||
GROUP="monty" \ | ||
PASSWORD="monty" | ||
RUN groupadd ${GROUP} && \ | ||
useradd -ms /bin/bash -g ${GROUP} -G sudo ${USER} && \ | ||
echo "${USER}:${PASSWORD}" | chpasswd | ||
ENV HOME="/home/${USER}" | ||
RUN chown -R ${USER}:${USER} ${HOME} | ||
USER ${USER} | ||
|
||
# Copy tutorial notebooks and example scripts to home directory | ||
WORKDIR ${HOME} | ||
RUN git clone https://github.com/brian-team/brian2.git \ | ||
&& mv brian2/examples examples \ | ||
&& mv brian2/tutorials tutorials \ | ||
&& chmod -R +x tutorials \ | ||
&& chmod -R +x examples \ | ||
&& find . -name '*.ipynb' -exec jupyter trust {} \; \ | ||
&& rm -rf brian2 | ||
|
||
EXPOSE 8888 | ||
CMD ["jupyter", "lab", "--ip=0.0.0.0", "--no-browser"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Instructions | ||
============ | ||
|
||
To build the image manually for testing on a local host for the native architecture: | ||
|
||
`docker build -t briansimulator/brian -f docker/Dockerfile .` | ||
|
||
Alternatively, to test multi-architecture builds and push to docker hub, first login: | ||
|
||
`docker login` | ||
|
||
Then execute: | ||
|
||
`docker buildx build --push --platform linux/amd64,linux/arm64/v8 -o type=image -t briansimulator/brian -f docker/Dockerfile .` | ||
|
||
Finally, to run the image: | ||
|
||
`docker run -it --init -p 8888:8888 briansimulator/brian` | ||
|
||
Or if you prefer a simple `bash` terminal rather than JupyterLab: | ||
|
||
`docker run -it --init briansimulator/brian /bin/bash` | ||
|
||
Or to run the tests: | ||
|
||
`docker run -it --init --rm briansimulator/brian python -c 'import brian2; brian2.test(test_standalone="cpp_standalone")'` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be preferable to get the architecture from the image directly with something like:
dpkg --print-architecture
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make clear that there is no misunderstanding: this is not an argument that you need to set, it is coming from docker (https://docs.docker.com/build/building/variables/#multi-platform-build-arguments). I understood that I have to declare them like this (but I didn't actually test it):
But there might be another way that is easier – ideally something that uses the same terminology as the pip wheel file names…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough - six of one, half a dozen of the other I guess 🤷♂️