| 1 |
# Docker instructions |
| 2 |
|
| 3 |
## Run docker image |
| 4 |
To run the docker image, you can use |
| 5 |
|
| 6 |
`docker run -it --init -p 8888:8888 briansimulator/brian` |
| 7 |
|
| 8 |
This will start a JupyterLab instance inside the container, which you can access from your local browser via the last link |
| 9 |
printed to the terminal (`http://127.0.0.1:8888/lab?token=…`) |
| 10 |
|
| 11 |
Or if you prefer a simple `bash` terminal rather than JupyterLab: |
| 12 |
|
| 13 |
`docker run -it --init briansimulator/brian /bin/bash` |
| 14 |
|
| 15 |
Or to run the tests: |
| 16 |
|
| 17 |
`docker run -it --init --rm briansimulator/brian python -c 'import brian2; brian2.test(test_standalone="cpp_standalone")'` |
| 18 |
|
| 19 |
## Build docker image |
| 20 |
To build the docker image locally, follow the following instructions: |
| 21 |
|
| 22 |
### Build package wheel |
| 23 |
You need to first build the package wheel(s) for linux using [`cibuildwheel`](https://cibuildwheel.readthedocs.io). Install it via |
| 24 |
`pip install cibuildwheel` (or use `pipx`) |
| 25 |
|
| 26 |
#### Build wheel for local architecture |
| 27 |
Run `cibuildwheel` to build a package for your architecture: |
| 28 |
``` |
| 29 |
export CIBW_BUILD='cp312-manylinux*' |
| 30 |
cibuildwheel --platform linux --arch auto64 --output-dir dist |
| 31 |
``` |
| 32 |
|
| 33 |
#### Build multi-arch wheel |
| 34 |
First install `qemu` for cross-compilation, e.g. on Debian/Ubuntu: |
| 35 |
|
| 36 |
`sudo apt install qemu-user-static` |
| 37 |
|
| 38 |
Then, run |
| 39 |
``` |
| 40 |
export CIBW_BUILD='cp312-manylinux*' |
| 41 |
cibuildwheel --platform linux --arch auto64,aarch64 --output-dir dist |
| 42 |
``` |
| 43 |
|
| 44 |
### Build docker image |
| 45 |
|
| 46 |
You can then build the docker image via |
| 47 |
|
| 48 |
`docker build -t briansimulator/brian -f docker/Dockerfile .` |
| 49 |
|
| 50 |
Alternatively, to test multi-architecture builds and push to docker hub, first login: |
| 51 |
|
| 52 |
`docker login` |
| 53 |
|
| 54 |
Create a new builder that uses the docker-container driver (only needed once): |
| 55 |
``` |
| 56 |
docker buildx create \ |
| 57 |
--name container \ |
| 58 |
--driver=docker-container \ |
| 59 |
default |
| 60 |
``` |
| 61 |
Then execute: |
| 62 |
|
| 63 |
``` |
| 64 |
docker buildx build \ |
| 65 |
--builder=container \ |
| 66 |
--push \ |
| 67 |
--platform linux/amd64,linux/arm64/v8 \ |
| 68 |
-o type=image \ |
| 69 |
-t briansimulator/brian \ |
| 70 |
-f docker/Dockerfile \ |
| 71 |
. |
| 72 |
``` |