==========
== 0x2f ==
==========

Which Anki sync server should I pick?

EDIT: Some more organizational info here https://github.com/ankicommunity/.github/issues/1

There are many repos containing Anki sync server implementations:

Which one should I use?

None of the ones listed above.

It’s hard to see (because only one of the above repos mentions it, would be nice if those repos were archived), but the sync server implementations were moved to the core repo https://github.com/ankitects/anki

Then, if you CAREFULLY read https://docs.ankiweb.net/sync-server.html instead of skimming it like an idiot (I know I did), you’ll see these:

While using the TrueNAS SCALE Anki app from TrueCharts, which still relies on the ankicommunity/anki-devops-services, which relies on kuklinistvan/anki-sync-server, I’m getting this error when using Anki Desktop 23.10 after I log in and try to sync:

JsonError { info: "missing field `media_usn` at line 1 column 114" }

So I decided to switch to using the latest server implementation from the core ankitects/anki repo.

Is there a Docker image for the servers in the official repo?

EDIT: There is now a semi-official Docker image of the OFFICIAL ankitects/anki server here:
https://github.com/LuckyTurtleDev/docker-images/tree/main/dockerfiles/anki
https://github.com/LuckyTurtleDev/docker-images/pkgs/container/anki
It’s hosted on the GitHub Container Registry rather than Dockerhub, so use the slightly longer URL - docker pull ghcr.io/luckyturtledev/anki:23.12

Old content before the above edit about Docker:
There’s no official docker image for the sync servers at https://github.com/ankitects/anki

Well, there is a Dockerfile https://github.com/ankitects/anki/tree/main/docs/docker but it fails during build due to missing cargo command

What you’re asking for used to be provided by https://github.com/ankicommunity/anki-devops-services (and sadly this is what the TrueNAS TrueCharts app uses). It uses the kuklinistvan/anki-sync-server repo, which of course - isn’t the official implementation from the official repo. I suspect what could’ve happened is that the code could have been just moved from anki-sync-server to the official repo and it’s not THAT different, but I didn’t check.

Making the Docker image yourself

Anyway, to use the server implementation from the core repo I just wrote this:

FROM rust:1.73
# need to install package or sync server build fails
RUN apt-get update && apt-get install protobuf-compiler -y
RUN cargo install --git https://github.com/ankitects/anki.git anki-sync-server
ENV SYNC_USER1=user:pass
CMD anki-sync-server

It’s probably stupid to imbue the SYNC_USER1=user:pass at build time as the creds are meant to be injected at run time (through TrueNAS’s Apps’ form “Environment Variables field”), but I just really wanted to get it done and over with.

Making TrueNAS use the image

I use TrueNAS SCALE and I just built the above Dockerfile using the shell: docker build . -t anki --network=host

then I created a TrueNAS app (Apps > Launch Docker Image) that uses the image:

  • Image repository: anki (because of “-t anki” when building above)
  • Image Pull Policy: Never pull image even if it’s not present on the host
  • Port Forwarding > Container port: 8080; Node Port: (anything you want, I picked 9271); TCP Protocol
  • Storage > Host Path: (path where you want to keep anki data); Mount path: /root/.syncserver;

Then just set your Anki Desktop or AnkiDroid to http://[yourip]:9721 and use the login and password “user” and “pass”. The data should persist between restarts because of the /root/.syncserver mount.

And also using the sync server implementation from the ankitects/anki repo fixed the "missing field media_usn" error on Anki Desktop 23.10 for me. Which is nice.