Dockerfile in `docs/docker` fails to build
The Dockerfile located in docs/docker fails to build because cargo is not installed on the image.
This is likely due to the build system having been changed recently, while the Dockerfile has not been updated to match.
Steps to reproduce
cd docs/docker
docker build --tag anki --file Dockerfile ../../
Error
./ninja: line 16: cargo: command not found
Full log
Click to expand
[+] Building 2.2s (13/19) docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 2.09kB 0.0s
=> WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 23) 0.0s
=> WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 32) 0.0s
=> [internal] load metadata for docker.io/library/python:3.9-slim 1.0s
=> [internal] load metadata for docker.io/library/python:3.9 1.0s
=> [auth] library/python:pull token for registry-1.docker.io 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 66B 0.0s
=> [build 1/5] FROM docker.io/library/python:3.9@sha256:10c3875a6435af5b2461c6f99c52bfa11716aae0ca8b27b77f81df9faab93b16 0.0s
=> CACHED [installer 1/4] FROM docker.io/library/python:3.9-slim@sha256:914169c7c8398b1b90c0b0ff921c8027445e39d7c25dc440337e56ce0f2566e6 0.0s
=> [internal] load build context 0.7s
=> => transferring context: 61.00MB 0.7s
=> CACHED [installer 2/4] WORKDIR /opt/anki/ 0.0s
=> CACHED [build 2/5] RUN curl -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.7.4/bazelisk-linux-amd64 > /usr/local/bin/bazel && chmod +x /usr/l 0.0s
=> CACHED [build 3/5] WORKDIR /opt/anki 0.0s
=> [build 4/5] COPY . . 0.2s
=> ERROR [build 5/5] RUN ./tools/build 0.2s
------
> [build 5/5] RUN ./tools/build:
0.130 ./ninja: line 16: cargo: command not found
------
2 warnings found (use docker --debug to expand):
- FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 23)
- FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 32)
Dockerfile:20
--------------------
18 | COPY . .
19 | # Build python wheels.
20 | >>> RUN ./tools/build
21 |
22 | # Install pre-compiled Anki.
--------------------
ERROR: failed to build: failed to solve: process "/bin/sh -c ./tools/build" did not complete successfully: exit code: 127
Docker support was contributed by someone years ago, but it's not maintained much or used by any of the frequent developers as far as I know, so it might take a while to fix issues here.
Could probably take a look at this if it is of interest. I'm guessing that being able to run Anki in a docker container is not widely used?
From what I can see, due to changes in the build system as mentioned by @peppapig450, the Dockerfile will have to be overhauled.
I have started working on a new one, correct me if I am wrong, but the docker image is only ever used when building documentation?
I made some changes to the dockerfile e-hamrin/anki#5826bcc1aa545908d647d32d29e9c81042e64f8f
Does this work for you aswell @peppapig450 ?
Yes that indeed works for me as well. Thanks! And it's probably inconsequential because the actual build dominants the time, but you could use uv for installing python and avoid pyenv entirely.
Nice!
Yeah you are right. Made a new one using uv to install python. https://github.com/ankitects/anki/commit/c41d6e13f6a21faf42453c41679609a12c741175
PR #4321