ankicommunity / anki-devops-services Goto Github PK
View Code? Open in Web Editor NEWAnki Sync Server with Docker - and it works!
License: GNU General Public License v3.0
Anki Sync Server with Docker - and it works!
License: GNU General Public License v3.0
Hi again István,
The client is AnkiDroid 2.11.3, whilst the server is running a self-built image for my Pi's ARM architecture, following your response to kuklinistvan/docker-anki-sync-server#11.
The server is confirmed to be accessible on the local network through 192.168.x.x, if I try curl 192.168.x.x
, it returns Anki Sync Server
, as expected. However, after setting up an account and trying to login on AnkiDroid:
If the Sync url
is set as https://192.168.x.x:27701/
, trying to login returns the following dialog box:
SSLException while building HttpClient
, which is likely because 192.168.x.x doesn't support https.
Ok, let's set Sync url
as http://192.168.x.x:27701/
instead. Trying to login now returns the following dialog box:
java.net.UnknownServiceException: CLEARTEXT communication to 192.168.x.x not permitted by network security policy
. After a search or two, I think either Android (I'm using Android 10) or AnkiDroid are enforcing https on login.
This may be an issue due to connecting to a 192.168.x.x address instead of an 127.0.0.1 address, perhaps Android or AnkiDroid allow http login on 127.0.0.1 but not 192.168.x.x. But, I can't access 127.0.0.1 from devices other than my Pi.
As far as I'm aware, I cannot add https to 192.168.x.x as it's not a domain. The best case scenario would be able to login without https as I have no need for it.
The only solution I can think of is to setup a reverse proxy to a domain and add https to the domain, but it sounds like a very roundabout way of solving it.
Any advice?
When I log in, it shows that the username and password are wrong
Reproduction (what did you do - the more details you give, the better):
1 docker deployment
2 Username and password have been set
log:
auth.db found
,collections directory exists
,No outdated 'auth' table found.
,Starting tsudoko's anki-sync-server
,No outdated 'session' table found.
,Updating database schema
,[2021-01-02 14:50:29,852]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16
,ankisyncd.conf found
,[2021-01-02 14:49:42,327]:INFO:ankisyncd:ankisyncd [unknown version] (https://github.com/tsudoko/anki-sync-server)
,[2021-01-02 14:49:42,337]:INFO:ankisyncd:Loaded config from /app/anki-sync-server/ankisyncd.conf
,[2021-01-02 14:49:42,337]:INFO:ankisyncd.users:Found auth_db_path in config, using SqliteUserManager for auth
,[2021-01-02 14:49:42,339]:INFO:ankisyncd.sessions:Found session_db_path in config, using SqliteSessionManager for auth
,[2021-01-02 14:49:42,340]:INFO:ankisyncd:Serving HTTP on 0.0.0.0 port 27701...
,[2021-01-02 14:49:47,065]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16
,[2021-01-02 14:49:52,539]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16
,[2021-01-02 14:50:03,211]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16
,[2021-01-02 14:49:57,872]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16
,[2021-01-02 14:50:08,547]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16
,[2021-01-02 14:50:13,863]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16
,[2021-01-02 14:50:19,204]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16
,[2021-01-02 14:50:24,536]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16
,[2021-01-02 14:50:35,195]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16
,[2021-01-02 14:50:40,527]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16
,[2021-01-02 14:50:45,877]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16
What was expected to happen:
What happened instead (the more details you give, the better):
Reproduction (what did you do - the more details you give, the better):
click the "sync" button
What was expected to happen:
sync sucessful.
What happened instead (the more details you give, the better):
your client is using unsupported sync protocol(10, supported version:9)
- Docker
- djankiserv
- legacy_tsudoko
- Docker Componse
- djankiserv
- djankiserv
- images (docker)
- examples (docker compose)
- manifests (kubernates)
- charts (helm)
- anki-sync-server (legacy_tsudoko)
- images
- ...
Because the images aren't related, it's better to store them separately. The benefit of this, is that you minimise the shared code so you can make changes to one image without making changes to another.
What do you think @kuklinistvan ?
when click in sync...
conection error
error decoding response body: missing field mod at line 1 column 99
seconds later...
anki id and password are wrong
I can`t use docker image and anki desktop, latest version both and i have installed Djankiserv connect
Hi Community,
I added a HEALTHCHECK test to the docker image by included this line at the end of Dockerfile:
HEALTHCHECK --interval=30s --timeout=3s \
CMD wget -q -O - http://127.0.0.1:27701/ || exit 1
This check every 30s if server is up and let 3s to respond.
I think it could be good to add it directly in the Dockerfile.
Best Regards,
Memiks.
Hello, i've set up an Anki Sync Server, with this Docker Image:
https://hub.docker.com/r/ankicommunity/anki-sync-server
Now i have the Problem, that i can enter the command line of the docker container, but the commands aren't working anymore. What are the new commands for the container?
It would be happy if someone could help me.
Thank you in advance :)
I tried to install this docker image on ubuntu server for ARM 64 bit and it failed miserably with
"anki-sync-server_1 | standard_init_linux.go:211: exec user process caused "exec format error""
I didn't realised the image was not compatible with ARM (im a noob to docker too)
Reproduction (what did you do - the more details you give, the better):
create docker-compose.yml as explained
ran docker-compose up
What was expected to happen:
the docker work normally.
What happened instead (the more details you give, the better):
What would be nice
a procedure to install it on ARM architecture. raspberry are inexpensive for student like me and quite handy
I would be glad to help altough i have very limited knowledge of docker
After setting up my Anki server by going through docker-anki-sync-server, recently I upgraded my Anki server to https. Since then the latest AnkiDroid (2.12.1) works perfect, right now I am wondering could I upgrade my AnkiDesktop(Version 2.1.19) to the latest version? is there anyone has done ?
Thank you!
I tried building the anki-sync-server
on my Raspberry PI (architecture: aarch64
) but failed to do so as anki==2.1.49
couldn't be found.
Manually following https://docs.ankiweb.net/sync-server.html worked fine but when I try to build and run a docker container with it it also fails.
Also, I'm a bit confused. What's the difference between this repo and https://github.com/ankicommunity/anki-sync-server?
Installed anki sync server through docker-compose
Anki sync server is working
Docker container kept restarting with error standard_init_linux.go:211: exec user process caused "exec format error"
which happens because of different architectures
We've now got a CI for https://github.com/ankicommunity/anki-sync-server. It needs a docker image for build process. I'm currently using this this image but it doesn't allow building the lastest verson of the psutil
library.
Adding this would fix that:
$ RUN apk add --update gcc libc-dev linux-headers && rm -rf /var/cache/apk/*
Source: giampaolo/psutil#664.
Alternatively, we could have separate development and prod images, which would probably be better in the long term.
Hey I build the image from source because the one from dockerhub doesn't seem to work.
Can you tell us where the data is stored so we can map it?
Reproduction (what did you do - the more details you give, the better):
Deployed to Azure app service with no changed to the docker-compose other than changing the volume binds to use app service storage.
What was expected to happen:
An Anki app would appear at its assigned URL.
What happened instead (the more details you give, the better):
The web page displays, 'A server error occurred. Please contact the administrator.' From the log below it appears a referenced SQLlite table is not found:
2020-11-30T12:26:06.114397919Z: [ERROR] cursor.execute(self.fs("SELECT skey, username, path FROM session WHERE hkey=?"), (hkey,))
2020-11-30T12:26:06.114401819Z: [ERROR] sqlite3.OperationalError: no such table: session
2020-11-30T12:26:06.116739669Z: [ERROR] [2020-11-30 12:26:06,116]:INFO:ankisyncd.http:172.16.32.1 "GET /favicon.ico HTTP/1.1" 500 59
2020-11-30T12:26:14.727875828Z: [ERROR] Traceback (most recent call last):
2020-11-30T12:26:14.727901729Z: [ERROR] File "/usr/local/lib/python3.7/wsgiref/handlers.py", line 137, in run
2020-11-30T12:26:14.727907029Z: [ERROR] self.result = application(self.environ, self.start_response)
2020-11-30T12:26:14.727911029Z: [ERROR] File "/usr/local/lib/python3.7/site-packages/webob/dec.py", line 129, in __call__
2020-11-30T12:26:14.727915029Z: [ERROR] resp = self.call_func(req, *args, **kw)
2020-11-30T12:26:14.727918629Z: [ERROR] File "/usr/local/lib/python3.7/site-packages/webob/dec.py", line 193, in call_func
2020-11-30T12:26:14.727922629Z: [ERROR] return self.func(req, *args, **kwargs)
2020-11-30T12:26:14.727926229Z: [ERROR] File "/app/anki-sync-server/ankisyncd/sync_app.py", line 506, in __call__
2020-11-30T12:26:14.727941529Z: [ERROR] session = self.session_manager.load(hkey, self.create_session)
2020-11-30T12:26:14.727944929Z: [ERROR] File "/app/anki-sync-server/ankisyncd/sessions.py", line 76, in load
2020-11-30T12:26:14.727948330Z: [ERROR] cursor.execute(self.fs("SELECT skey, username, path FROM session WHERE hkey=?"), (hkey,))
2020-11-30T12:26:14.727963730Z: [ERROR] sqlite3.OperationalError: no such table: session
2020-11-30T12:26:14.730837290Z: [ERROR] [2020-11-30 12:26:14,730]:INFO:ankisyncd.http:172.16.32.1 "GET / HTTP/1.1" 500 59
2020-11-30T12:26:14.850312980Z: [ERROR] Traceback (most recent call last):
2020-11-30T12:26:14.850338880Z: [ERROR] File "/usr/local/lib/python3.7/wsgiref/handlers.py", line 137, in run
2020-11-30T12:26:14.850344180Z: [ERROR] self.result = application(self.environ, self.start_response)
2020-11-30T12:26:14.850349481Z: [ERROR] File "/usr/local/lib/python3.7/site-packages/webob/dec.py", line 129, in __call__
2020-11-30T12:26:14.850353281Z: [ERROR] resp = self.call_func(req, *args, **kw)
2020-11-30T12:26:14.850363181Z: [ERROR] File "/usr/local/lib/python3.7/site-packages/webob/dec.py", line 193, in call_func
2020-11-30T12:26:14.850367781Z: [ERROR] return self.func(req, *args, **kwargs)
2020-11-30T12:26:14.850371081Z: [ERROR] File "/app/anki-sync-server/ankisyncd/sync_app.py", line 506, in __call__
2020-11-30T12:26:14.850374681Z: [ERROR] session = self.session_manager.load(hkey, self.create_session)
2020-11-30T12:26:14.850378081Z: [ERROR] File "/app/anki-sync-server/ankisyncd/sessions.py", line 76, in load
2020-11-30T12:26:14.850388981Z: [ERROR] cursor.execute(self.fs("SELECT skey, username, path FROM session WHERE hkey=?"), (hkey,))
2020-11-30T12:26:14.850392881Z: [ERROR] sqlite3.OperationalError: no such table: session
2020-11-30T12:26:14.851792811Z: [ERROR] [2020-11-30 12:26:14,851]:INFO:ankisyncd.http:172.16.32.1 "GET /favicon.ico HTTP/1.1" 500 59
Syncing seems to work but still leads to the following exception in the app:
org.json.JSONException: A JSONObject text must begin with '{' at character 1 of Anki sync Server.
Reproduction (what did you do - the more details you give, the better):
Running docker-anki-sync-server behind reverse proxy.
What was expected to happen:
regular sync
What happened instead (the more details you give, the better):
Pulled docker container from dockerhub
latest, digest: ab631f3845d1
Exception in the [App](url
logs.txt
)
when login clicked,show unknow usr or passwd
When using docker to install ankicommunity/anki-sync-server
, an error occurs.
sudo docker run -itd \
--mount type=bind,source="$PERSISTENCE_DIR",target=/app/data \
-p 27701:27701 \
--name anki-container \
--restart always \
ankicommunity/anki-sync-server:latest-develop
Working well.
Installed but failed to start.
docker: Error response from daemon: OCI runtime create failed: invalid mount {Destination:collections Type:bind Source:/var/lib/docker/volumes/fdf12f3eb3d9a16a6427f50b0fd03d2b686ac08501d7dadb0bbaa4ae4fd98cb7/_data Options:[rbind]}: mount destination collections not absolute: unknown.
I tried to setup the sync server but I got the error message "Your client is using unsupported sync protocol (10, supported version: 9)" in AnkiDroid (current version) after using the comands from here (https://github.com/ankicommunity/anki-devops-services?tab=readme-ov-file) )to create a user.
Issue is also mentioned here (ankicommunity/ankicommunity-sync-server#13) als closed, but it seams not closed for the docker container. So please update the docker container to be able to use it with the current version of AnkiDroid.
docker compose:
`version: "3"
services:
anki-container:
image: kuklinistvan/anki-sync-server:latest
container_name: Anki
ports:
- 27701:27701
volumes:
- /volume1/docker/anki/data:/app/data
restart: always
volumes:
data:`
Forks are treaded as second class citizens on Github. There was also a discussion on the anki-sync-server
about how it causes confusion: ankicommunity/ankicommunity-sync-server#2.
You can see how here: https://stackoverflow.com/questions/18390249/github-make-fork-an-own-project. It involves contacting support. When I did it for the above, I just send them the ticket, and asked them to do it.
I just wanted to run it by you. Let me know what you think?
Hi,
Thanks for the awesome work with all of this. I just wish I could get it setup properly on my end ... :'(
Any chance a super-noob friendly guide can be thrown out by someone? I am on mac/osx. Docker installed fine. anki-sync-server installed fine to Docker. Cool. And it runs. And the CLI button provides a prompt that allows me to setup an account.
Great.
However, I cannot connect to this server. I am guessing it might have something to do with the directory not being set up properly? But, really, I have no clue. Any chance for a step-by-step -- e.g., the steps to reproduce the "test" mentioned in RM?
Thanks in advance! <3 <3
Hello guys,
I found it very difficult to understand, how these repos are connected together. so I then made myself and made a simple diagram. in doing so, i came across the question, why don't you take your own anki sync server out of the organization. that made it very difficult for me to understand.
I suggest to update the git submodule to the organizations anki sync server.
This repo provides a Dockerfile
and docker-compose.yml
for 2 separate sources and -as far as I understand- currently independent servers.
I think this is misleading. I really would have tried this if I understood there was a branch with the docker-compose but the name of the repo suggested it was the other repo's docker-compose...
I think that at a minimum the two repo should be separated so that it's clear before opening the repo what you will find inside. In fact not even the readme suggests there is a docker-compose for djankiserv.
A separate issue is the fact that Dockerfile
and docker-compose.yml
should or not be kept together with the sources. For the repo I administer I normally keep Dockerfile
with the code so that an image is created by gitlab on commit and separately I have a Dockerfile
that normally is much more dependent on how you decide to deploy (Anton suggested in fact to use microk8s that is probably a very good idea).
Since the docker can be done in many ways (uwsgi in single docker rather than gunicorn with separate static docker, mysql or postgresql, ...) we could just as well decide to go with different repositories, but if we agree on one docker we probably don't need to have so many options.
i use the origin anki-sync-server plugin, which is to put this code in the addons21
`
//init.py
import anki.sync, anki.hooks, aqt
addr = "https://yieatn.ltd:27702/" # put your server address here
anki.sync.SYNC_BASE = "%s" + addr
def resetHostNum():
aqt.mw.pm.profile['hostNum'] = None
anki.hooks.addHook("profileLoaded", resetHostNum)`
this way work fine on 2.1.20, but fail on 2.1.30
it says wrong username and passwd
i guess the original init.py can't work on 2.1.30
I was asked to bring here some of the remarks on this docker-compose file (of djankiserv) and I'm pleased to do it in this issue. In a separate issue, I'll discuss whether we want a repo for the dockerfile/docker-compose or if it's better to keep it together with the source repo. Here I'll start reporting what I already stated in gitter, it's clear that I already proposed a working docker-compose.yml
that in my opinion already has all the possible needs in a single pretty readable file (maybe too many options: proxy via ngrok,
via mitmproxy
, deploy via nginx
or traefik
).
My goal was similar: produce a no-brainer configuration.
Here I will report some of the remarks I would raise to the current solution in this repo:
One single repo for 2 different servers? do we need this? isn't the name of the repo misleading for the djankiserv docker-compose file? I honestly didn't understand there was a branch with a docker-compose until after I published my version.
Use of scripts to generate configuration rather than leaning on the .env
file? As you can see in my repo, a very simple .env
file can show all variables needed, that's not only the official way but is also very readable. This split up the configuration in many different places and I got lost.
I don't like to have a completely new settings file, I'd prefer to see differences in a local_settings.py that overwrites the other one but only where it is different so that it's much easier to spot where the two diverge. Anton has made an app -djankiserv
- and a project. The project is functional just to show the app is working and we should let the developer in the position to use it. IMO if you really want to shove in a lot of customization, you're better off using the app and integrating it into your project.
I suggest to refrain from using spaces in folder/file names, it's so uneasy from the cli... (Docker Compose)
(ok, you already agreed)
I don't really understand where you initialize the postgresql db (creation of 2 different db). Be carefull! Django does not create databases, migrations will create tables, and so on but inside the connection declared in the settings. It's correct that Django does not (technically you could it the user is a superuser and if you have such a migration, but please: don't).
My solution is to let it be done by the configuration of the initialization scripts of the PostgreSQL container, as described by PostgreSQL team.
I'm not sure I want to create migration as CMD in Dockerfile, which prevents from starting the container if the db is not there and would all the times try to migrate.
Where would you place the initial (and further) migration command? I've placed it there because that way it works automatically.
Migrations are done separately. That's a possible important modification of your data, it's the user that decides to do it:
docker-compose up -d
docker-compose exec django manage.py migrate
I've also set the container configuration to restart: always to keep polling the database while it becomes available.
we have the directivedepends_on
for that, no need to poll
manage.py runserver
is mono thread and anyhow not suitable for production. Gunicorn
and uwsgi
are much more robust.
(you already agreed)
1 or 2 containers? when deploying containers I always put a load balancer in front that handles the traefik for a bunch of dockers so I believe that we can count on that. I personally use traefik as it handles letsencrypt certificate and is born to work with containers (I have used nginx for over 15 years in traditional deployments, apache for the previous 10 years). Traefik is able to detect when a docker is run and route traefik only in that situation. In these cases, you don't need an Nginx for that and we can just have one single container if we use uwsgi that has the possibility to serve static files in a pretty efficient way. So you would not need 2 dockers on hub.docker.com. [I really cannot understand why my container is not showing up in the search result]
As I believe this is mainly addressed to developers that want to play with these servers I wanted to add mitmproxy
and ngrok
that can greatly help to understand what is going to happen under the hood. This is probably a bit daunting as the readme bloated significantly as the possible setup increase... I'm interested in understanding if you find it difficult to read. I also considered to have a "user" and a "developer" configuration but probably if you already setup docker-compose. you're not a "normal" user...
Hi,
I am trying to follow the instructions here: https://ankicommunity.github.io/Tutorials/Docker/Howto/
I have set up the docker, confirmed using the hello world command as per here https://ankicommunity.github.io/Tutorials/Docker/Howto/
Now I am trying to run this command
docker run -it
--mount type=bind,source="$PERSISTENCE_DIR",target=/app/data
-p 27701:27701
--name anki-container
--rm
$DOCKER_IMAGE
I have substituted: "$DOCKER_IMAGE" with "kuklinistvan/anki-sync-server:latest"
I have substitute: "$PERSISTENCE_DIR" with /home/aa/anki-sync-server-persistence
Where aa is my username/login
and anki-sync-server-persistence is the folder in my home location which I made using new folder
This leaves me with
docker run -it
--mount type=bind,source="/home/aa/anki-sync-server-persistence",target=/app/data
-p 27701:27701
--name anki-container
--rm
kuklinistvan/anki-sync-server:latest
However, I keep getting the following error:
docker run -it \
--mount type=bind,source="/home/aa/anki-sync-server-persistence/
",target=/app/data \
invalid argument "type=bind,source=/home/aa/anki-sync-server-persistence/\n,target=/app/data" for "--mount" flag: target is required
See 'docker run --help'.
I know there must be something wrong with the code I have entered. I have tried it with and without the $ signs.
Please note this is my first time doing something like this so please don't exclude basic obvious things to you are the reason why its not working, because they may not be apparent to me and that could be the issue.
Thank you!
From https://ankiweb.net/shared/info/2124817646
Supported Anki versions:
2.1.19
And it's unable to install this by Addons Manager of Anki
We should remove https://github.com/ankicommunity/docker-anki-sync-server/blob/master/Docker/config/ankisyncd.conf.example and use environment variables (https://github.com/ankicommunity/anki-sync-server#envvar-configuration-overrides) instead.
This will simplify the build and more familiar to Docker users. This will be the preferred method of configuration in the future. Thoughts?
Hi,
I was just wondering why the anki-sync-server docker build requires audio / pyaudio? I realize that anki is capable of audio support (a feature I actually use in some of my decks). But I still don't understand why the sync-server needs audio support? Have I misunderstood a function of the sync server? I use it to synchronize anki decks between different instances of anki I have running (e.g. on different computers). Why does the server need or how does it utilize audio? Many thanks!
To the AnkiCommunity
Org.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.