Skip to content

Commit 65f45ea

Browse files
authored
Update docker build command for syncserver (#4562)
The command for building the image does not include the` --platform` flag which prevents the image from running across all architectures. For example, if I build the image on an ARM system and then try running on x86, it won’t work. This issue can be fixed by using `docker buildx` and adding the flag to include all of the platforms. I have tested this by building the image with the `linux/arm64` and `linux/amd64` platform flags on an ARM system and then running a container with that image on an x86 system. This would be useful in scenarios where the syncserver runs on devices that cannot do builds. The correct command would be ```bash # Builds for all existing platforms supported by Docker docker buildx build -f <Dockerfile> --platform linux/amd64,linux/arm64,windows/amd64 --no-cache --build-arg ANKI_VERSION=<version> -t anki-sync-server . ``` Reference: https://docs.docker.com/build/building/multi-platform/
1 parent c767930 commit 65f45ea

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ Brett Schwartz <brettschwartz871@gmail.com>
267267
Lovro Boban <lovro.boban@hotmail.com>
268268
Yuuki Gabriele Patriarca <yuukigpatriarca@gmail.com>
269269
SecretX <https://github.com/SecretX33>
270+
CYPHER0041 <48846390+CYPHER0041@users.noreply.github.com>
270271
Oli <https://github.com/oliolioli>
271272
DaedalusIndigo <260538003+DaedalusIndigo@users.noreply.github.com>
272273
Daniel Pechersky <danny.pechersky@gmail.com>

docs/syncserver/README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,32 @@ the build products and runtime dependencies from the rest of your system.
2828

2929
To proceed with building, you must specify the Anki version you want, by replacing `<version>` with something like `24.11` and `<Dockerfile>` with the chosen Dockerfile (e.g., `Dockerfile` or `Dockerfile.distroless`)
3030

31+
The `--platform` option specifies which systems the image will be able to run on after it has been built. This is helpful in scenarios where you are building the image on one architecture (eg: an M series Mac) but running the image on another architecture (eg: x86 Linux server).
32+
33+
- `linux/amd64` is for x86 linux systems (Images built with this option will work on Windows as well through WSL2 which is included with Docker Desktop)
34+
- `linux/arm64` is for ARM systems (eg: M series Macs)
35+
36+
On Linux systems, you will have to configure a custom builder which supports ARM builds first as shown below. You can then run the Mac build command in the next step.
37+
38+
```bash
39+
# Configuring multiplatform builder and activating it
40+
docker buildx create --name multiplatform-builder --driver docker-container --driver-opt default-load=true --bootstrap --use
41+
```
42+
43+
On M-series Macs running Docker Desktop, you can build for both platforms using the default builder by running the command below:
44+
45+
```bash
46+
# Execute this command from this directory
47+
docker buildx build -f <Dockerfile> --platform linux/amd64,linux/arm64 --no-cache --build-arg ANKI_VERSION=<version> -t anki-sync-server .
48+
```
49+
50+
If the build fails with `Resource Exhausted:.... cannot allocate memory`, go to Docker Desktop > Settings > Resources and increase the memory limit.
51+
52+
If you are unsure of what platform your system is, just run the command below without the platform option.
53+
3154
```bash
3255
# Execute this command from this directory
33-
docker build -f <Dockerfile> --no-cache --build-arg ANKI_VERSION=<version> -t anki-sync-server .
56+
docker buildx build -f <Dockerfile> --no-cache --build-arg ANKI_VERSION=<version> -t anki-sync-server .
3457
```
3558

3659
# Run container

0 commit comments

Comments
 (0)