From 012d4e14fccc06c44d32d2d0221e9d68115c59b4 Mon Sep 17 00:00:00 2001 From: lua Date: Sun, 17 Aug 2025 22:01:46 +0200 Subject: [PATCH 01/16] improves codebase --- .gitignore | 11 ++++++++++- config/app/Anki2/config.json | 9 +++++++++ config/app/backups/.gitkeep | 0 docker-compose.yml | 13 +++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 config/app/Anki2/config.json create mode 100644 config/app/backups/.gitkeep create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 5ab9782..89b79e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,11 @@ .env -docker-compose.yml +# Ignore everything in config +config/* + +# But don't ignore these specific files +!config/app/ +!config/app/Anki2/ +!config/app/Anki2/config.json +!config/app/Anki2/menu.xml +!config/app/backups/ +!config/app/backups/.gitkeep diff --git a/config/app/Anki2/config.json b/config/app/Anki2/config.json new file mode 100644 index 0000000..0b37179 --- /dev/null +++ b/config/app/Anki2/config.json @@ -0,0 +1,9 @@ +{ + "apiKey": null, + "apiLogPath": null, + "ignoreOriginList": [], + "webBindAddress": "0.0.0.0", + "webBindPort": 8765, + "webCorsOrigin": "http://localhost", + "webCorsOriginList": ["*"] +} diff --git a/config/app/backups/.gitkeep b/config/app/backups/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..710ef81 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +services: + anki-desktop: + build: + context: ./ + dockerfile: Dockerfile + environment: + - PUID=1000 + - PGID=1000 + volumes: + - ./config:/config + ports: + - 3000:3000 # Web UI + - 8765:8765 # AnkiConnect From c87ea99e9b0b90001c488221f46cb8fe7460090c Mon Sep 17 00:00:00 2001 From: lua Date: Sun, 17 Aug 2025 22:03:10 +0200 Subject: [PATCH 02/16] improves codebase --- README.md | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2655951..8ee1aaa 100644 --- a/README.md +++ b/README.md @@ -42,26 +42,21 @@ Also uses `curl` to call AnkiConnect. It forces a sync and optionally reschedule Create a `docker-compose.yml` in the root of the repo: ```yaml -services: - anki-desktop: - build: +services: + anki-desktop: + build: context: ./ dockerfile: Dockerfile environment: - PUID=1000 - PGID=1000 volumes: - - ~/.local/share/Anki2:/config/app/Anki2 - - ~/backups:/config/app/backups - ports: - - 3000:3000 - # Anki Connect port - - 8765:8765 - + - ./config:/config + ports: + - 3000:3000 # Web UI + - 8765:8765 # AnkiConnect ```` -* The **first volume** maps your local Anki data (on Ubuntu it's usually at `~/.local/share/Anki2`) into the container. -* The **second volume** is for backups you extract via AnkiConnect. To get started: From 04d15af22067dc304f9cd37f1dbc1c72716fd628 Mon Sep 17 00:00:00 2001 From: lua Date: Sun, 17 Aug 2025 22:21:25 +0200 Subject: [PATCH 03/16] improves codebase --- .gitignore | 9 ++------- Dockerfile | 6 ++---- README.md | 8 ++++---- {config/app/backups => anki_data}/.gitkeep | 0 config/app/Anki2/config.json | 9 --------- docker-compose.yml | 2 +- root/defaults/autostart | 4 +--- 7 files changed, 10 insertions(+), 28 deletions(-) rename {config/app/backups => anki_data}/.gitkeep (100%) delete mode 100644 config/app/Anki2/config.json diff --git a/.gitignore b/.gitignore index 89b79e2..dd9947c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,6 @@ .env # Ignore everything in config -config/* +anki_data/* # But don't ignore these specific files -!config/app/ -!config/app/Anki2/ -!config/app/Anki2/config.json -!config/app/Anki2/menu.xml -!config/app/backups/ -!config/app/backups/.gitkeep +!anki_data/.gitkeep diff --git a/Dockerfile b/Dockerfile index da82c36..db7928a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,10 +22,8 @@ RUN dpkg --remove anki && \ cd anki-launcher-${ANKI_VERSION}-linux && ./install.sh && cd .. && \ rm -rf anki-launcher-${ANKI_VERSION}-linux anki-launcher-${ANKI_VERSION}-linux.tar.zst -# Create a config directory to be mounted and add symbolic links to Anki's real config directories -RUN mkdir -p /config/.local/share && \ - ln -s /config/app/Anki /config/.local/share/Anki && \ - ln -s /config/app/Anki2 /config/.local/share/Anki2 +# Create a config directory to be mounted +RUN mkdir -p /config/.local/share COPY ./root / diff --git a/README.md b/README.md index 8ee1aaa..af2e81e 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,7 @@ Also uses `curl` to call AnkiConnect. It forces a sync and optionally reschedule ## Docker Compose Setup -Create a `docker-compose.yml` in the root of the repo: - +Use the `docker-compose.yml` in the root of the repo: ```yaml services: anki-desktop: @@ -72,12 +71,13 @@ Then open your browser and head to: http://localhost:3000 ``` +Press Enter after Anki is installed for the first time. Now you can use it as normal. In order to sync with the other clients, put your sync information in the Sync tab. + --- ## AnkiConnect Configuration -Make sure your AnkiConnect config (inside Anki) looks like this: - +If you want to expose the Anki client to http requests, make sure to install the [AnkiConnect](https://ankiweb.net/shared/info/2055492159) Add-on and to configure the Add-on with: ```json { "apiKey": null, diff --git a/config/app/backups/.gitkeep b/anki_data/.gitkeep similarity index 100% rename from config/app/backups/.gitkeep rename to anki_data/.gitkeep diff --git a/config/app/Anki2/config.json b/config/app/Anki2/config.json deleted file mode 100644 index 0b37179..0000000 --- a/config/app/Anki2/config.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "apiKey": null, - "apiLogPath": null, - "ignoreOriginList": [], - "webBindAddress": "0.0.0.0", - "webBindPort": 8765, - "webCorsOrigin": "http://localhost", - "webCorsOriginList": ["*"] -} diff --git a/docker-compose.yml b/docker-compose.yml index 710ef81..e1b1888 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: - PUID=1000 - PGID=1000 volumes: - - ./config:/config + - ./anki_data:/config ports: - 3000:3000 # Web UI - 8765:8765 # AnkiConnect diff --git a/root/defaults/autostart b/root/defaults/autostart index 01676c5..b322e14 100755 --- a/root/defaults/autostart +++ b/root/defaults/autostart @@ -1,9 +1,7 @@ # Set layout to avoid keybinding warnings setxkbmap -layout us & -sudo chown -R 1000:1000 /config/app && \ -mkdir -p /config/app/Anki2 && \ -mkdir -p /config/app/Anki +sudo chown -R 1000:1000 /config/app export DISABLE_QT5_COMPAT=1 export LC_ALL=en_US.UTF-8 From d5b6246d2f77d06fdc8d96c2ca88fd4baee5f51d Mon Sep 17 00:00:00 2001 From: lua Date: Sun, 17 Aug 2025 22:22:20 +0200 Subject: [PATCH 04/16] improves codebase --- .dockerignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 231219e..5b2b6c2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -16,6 +16,6 @@ sync docker-compose.yml # Runtime files -config/ +anki_data/ *.log From 28efcc6629c536b07993f4daf3ff2f6f4503b445 Mon Sep 17 00:00:00 2001 From: lua Date: Sun, 17 Aug 2025 22:27:28 +0200 Subject: [PATCH 05/16] improves codebase --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af2e81e..35087a9 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ The Anki desktop app runs in a browser (via VNC) on port `3000`. Your Anki data ## Files in This Repo ### `Dockerfile` -Builds the container with Anki 25.02.7 You can change the Anki version, but compatibility may vary. +Builds the container with Anki 25.07.5 You can change the Anki version, but compatibility may vary. ### `docker_installation` Contains commands to install Docker on Ubuntu. From 9f953615add04937cb940c243682e053c4d83758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lua=20=F0=9F=8C=88?= <65793493+mlcivilengineer@users.noreply.github.com> Date: Sun, 17 Aug 2025 22:37:34 +0200 Subject: [PATCH 06/16] Create docker-image.yml --- .github/workflows/docker-image.yml | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..d58578b --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,46 @@ +name: Build & Push (Docker Hub) + +on: + push: + branches: [ "main" ] + tags: [ "v*.*.*" ] + +jobs: + docker: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract repo name + id: repo + run: echo "name=${GITHUB_REPOSITORY#*/}" >> $GITHUB_OUTPUT + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.repo.outputs.name }} + tags: | + type=ref,event=branch + type=ref,event=tag + type=sha + + - name: Build & push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 4c1b1c7891ec61a88b83cf1392b5ceacff389c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lua=20=F0=9F=8C=88?= <65793493+mlcivilengineer@users.noreply.github.com> Date: Sun, 17 Aug 2025 22:41:06 +0200 Subject: [PATCH 07/16] Update docker-image.yml --- .github/workflows/docker-image.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d58578b..be60040 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -4,6 +4,7 @@ on: push: branches: [ "main" ] tags: [ "v*.*.*" ] + workflow_dispatch: jobs: docker: From 42e15460f81e30536270c0b1d91c1dc5b26cbf2d Mon Sep 17 00:00:00 2001 From: lua Date: Sun, 17 Aug 2025 22:51:06 +0200 Subject: [PATCH 08/16] improves codebase --- README.md | 37 ++++++++++++++++++++++++++----------- docker-compose.yml | 1 + 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 35087a9..0a26e04 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,32 @@ Also uses `curl` to call AnkiConnect. It forces a sync and optionally reschedule --- +## How to run + +If you want you can run this using the image `mlcivilengineer/anki-desktop-docker` which is automatically built using Github Actions in this repo. Use the following command: +```bash +docker run -d \ + --name anki-desktop \ + -e PUID=1000 \ + -e PGID=1000 \ + -v "$(pwd)/anki_data:/config" \ + -p 3000:3000 \ + -p 8765:8765 \ + mlcivilengineer/anki-desktop-docker:latest +``` + +Then open your browser and head to: + +``` +http://localhost:3000 +``` + +Press Enter after Anki is installed for the first time. Now you can use it as normal. In order to sync with the other clients, put your sync information in the Sync tab. + + ## Docker Compose Setup -Use the `docker-compose.yml` in the root of the repo: +If you prefer docker compose instead, use the `docker-compose.yml` in the root of the repo: ```yaml services: anki-desktop: @@ -50,7 +73,7 @@ services: - PUID=1000 - PGID=1000 volumes: - - ./config:/config + - ./anki_data:/config ports: - 3000:3000 # Web UI - 8765:8765 # AnkiConnect @@ -62,17 +85,9 @@ To get started: ```bash git clone cd anki-desktop-docker -docker compose up --build -d -``` - -Then open your browser and head to: - -``` -http://localhost:3000 +docker compose up -d ``` -Press Enter after Anki is installed for the first time. Now you can use it as normal. In order to sync with the other clients, put your sync information in the Sync tab. - --- ## AnkiConnect Configuration diff --git a/docker-compose.yml b/docker-compose.yml index e1b1888..aa3945d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,6 @@ services: anki-desktop: + image: mlcivilengineer/anki-desktop-docker:latest build: context: ./ dockerfile: Dockerfile From 449894e3df35f25fd341d5420c07b707bcf9ce8f Mon Sep 17 00:00:00 2001 From: lua Date: Sun, 17 Aug 2025 23:06:27 +0200 Subject: [PATCH 09/16] improves codebase --- root/defaults/autostart | 2 -- 1 file changed, 2 deletions(-) diff --git a/root/defaults/autostart b/root/defaults/autostart index b322e14..9258747 100755 --- a/root/defaults/autostart +++ b/root/defaults/autostart @@ -1,8 +1,6 @@ # Set layout to avoid keybinding warnings setxkbmap -layout us & -sudo chown -R 1000:1000 /config/app - export DISABLE_QT5_COMPAT=1 export LC_ALL=en_US.UTF-8 From 6793060d4e887f7a8abf1611e2576dd0d365da77 Mon Sep 17 00:00:00 2001 From: lua Date: Sun, 17 Aug 2025 23:13:53 +0200 Subject: [PATCH 10/16] improves codebase --- README.md | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0a26e04..fcf822d 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ docker run -d \ -v "$(pwd)/anki_data:/config" \ -p 3000:3000 \ -p 8765:8765 \ - mlcivilengineer/anki-desktop-docker:latest + mlcivilengineer/anki-desktop-docker:main ``` Then open your browser and head to: diff --git a/docker-compose.yml b/docker-compose.yml index aa3945d..5273071 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: anki-desktop: - image: mlcivilengineer/anki-desktop-docker:latest + image: mlcivilengineer/anki-desktop-docker:main build: context: ./ dockerfile: Dockerfile From ac75a168dbb4e39e6164cbae2c0a745548da25f7 Mon Sep 17 00:00:00 2001 From: lua Date: Sun, 17 Aug 2025 23:14:46 +0200 Subject: [PATCH 11/16] improves codebase --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fcf822d..23caa78 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ If you prefer docker compose instead, use the `docker-compose.yml` in the root o ```yaml services: anki-desktop: + image: mlcivilengineer/anki-desktop-docker:main build: context: ./ dockerfile: Dockerfile @@ -77,6 +78,7 @@ services: ports: - 3000:3000 # Web UI - 8765:8765 # AnkiConnect + ```` From 31fd6c4e40f09b248f106883012cf933d8df9bb0 Mon Sep 17 00:00:00 2001 From: lua Date: Sun, 17 Aug 2025 23:18:11 +0200 Subject: [PATCH 12/16] improves codebase --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 23caa78..31db210 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This project is inspired by [pnorcross/anki-desktop-docker](https://github.com/p Why? Because it makes automating Anki (with addons like AnkiConnect) easier. -The Anki desktop app runs in a browser (via VNC) on port `3000`. Your Anki data is stored in a volume mounted at `/config/app` inside the container. +The Anki desktop app runs in a browser (via VNC) on port `3000`. Your Anki data is stored in `anki_data` mounted as a volume at '/config` inside the container. --- From 5d4a1dac42391b2554eb8c20a7826fa9c3042cf6 Mon Sep 17 00:00:00 2001 From: Aken-2019 Date: Sun, 7 Sep 2025 16:22:45 +0200 Subject: [PATCH 13/16] add instructions of CJK support --- README.md | 15 +++++++++++++++ docker-compose.yml | 3 +++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 31db210..3675a31 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,21 @@ docker compose up -d --- +## Optional: CJK Font Support + +If you need support for Chinese, Japanese, or Korean (CJK) characters in your Anki cards, you can enable this by uncommenting the following environment variables in the `docker-compose.yml` file: + +```yaml +environment: + - PUID=1000 + - PGID=1000 + # Uncomment the following lines to enable CJK font support + - DOCKER_MODS=linuxserver/mods:universal-package-install + - INSTALL_PACKAGES=language-pack-zh-hans|fonts-arphic-ukai|fonts-arphic-uming|fonts-ipafont-mincho|fonts-ipafont-gothic|fonts-unfonts-core +``` + +After making these changes, rebuild your container for the changes to take effect. + ## AnkiConnect Configuration If you want to expose the Anki client to http requests, make sure to install the [AnkiConnect](https://ankiweb.net/shared/info/2055492159) Add-on and to configure the Add-on with: diff --git a/docker-compose.yml b/docker-compose.yml index 5273071..25fecde 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,9 @@ services: environment: - PUID=1000 - PGID=1000 + # Uncomment the following lines to enable CJK font support + # - DOCKER_MODS=linuxserver/mods:universal-package-install + # - INSTALL_PACKAGES=language-pack-zh-hans|fonts-arphic-ukai|fonts-arphic-uming|fonts-ipafont-mincho|fonts-ipafont-gothic|fonts-unfonts-core volumes: - ./anki_data:/config ports: From 3b623143b03ac90efca832a9cfc44dcd8894b37f Mon Sep 17 00:00:00 2001 From: qingliu Date: Fri, 26 Sep 2025 23:25:00 +0800 Subject: [PATCH 14/16] fix(config): update anki executable path - Change anki command path from /usr/bin/anki to /usr/local/bin/anki --- root/defaults/menu.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/defaults/menu.xml b/root/defaults/menu.xml index bc57f27..f17d04e 100644 --- a/root/defaults/menu.xml +++ b/root/defaults/menu.xml @@ -3,7 +3,7 @@ - /usr/bin/anki + /usr/local/bin/anki From 12911225ceb94b2570189dfb4203af97ee79c07d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lua=20=F0=9F=8C=88?= <65793493+mlcivilengineer@users.noreply.github.com> Date: Thu, 9 Oct 2025 20:38:09 +0200 Subject: [PATCH 15/16] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..467d7a0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Lua 🌈 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 72ef785f28499a05fd59bdfc84e918bd8f1ad34f Mon Sep 17 00:00:00 2001 From: lua Date: Thu, 30 Oct 2025 22:35:31 +0100 Subject: [PATCH 16/16] Your single squashed commit message --- Dockerfile | 2 ++ root/defaults/menu.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index db7928a..87e2f6b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,8 @@ RUN apt-get update && \ libxcb-xinerama0 \ libxcb-cursor0 \ python3-xdg \ + lame \ + mplayer \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/root/defaults/menu.xml b/root/defaults/menu.xml index bc57f27..18427c9 100644 --- a/root/defaults/menu.xml +++ b/root/defaults/menu.xml @@ -3,7 +3,7 @@ - /usr/bin/anki + /usr/local/bin/anki