Commit Graph

16 Commits

Author SHA1 Message Date
Jean Khawand
60aa8bf816 fix(syncserver): use built-in --healthcheck instead of wget (#5044)
The wget probe logs a line on every interval, polluting container stdout
in Docker and k3s. The --healthcheck flag exits 0/1 silently, letting
the platform report health without log noise.
2026-06-26 14:02:47 +03:00
RedPine404
29a2853f1d fix: Bump rust builder and base image for syncserver (#5036)
## Linked issue (required)

Fixes #5035

## Summary / motivation (required)

Rust builder is outdated an no longer builds the syncserver
successfully.

Bumping the version to match rust-toolchain.toml version 1.92.0 fixes
this issue.

I also bumped the base image to alpine:3.23 as alpine:3.21.0 is over a
year old.

## Steps to reproduce (required, use N/A if not applicable)

docker buildx build -f <Dockerfile> --no-cache --build-arg
ANKI_VERSION=<version> -t anki-sync-server .

## How to test (required)

docker buildx build -f <Dockerfile> --no-cache --build-arg
ANKI_VERSION=<version> -t anki-sync-server .

### Checklist (minimum)

- [x] I ran `docker buildx build -f Dockerfile --no-cache --build-arg
ANKI_VERSION=26.05 -t anki-sync-server .`
- [x] I ran `docker buildx build -f Dockerfile.distroless --no-cache
--build-arg ANKI_VERSION=26.05 -t anki-sync-server .`

### Details

Docker image compiled as expected following the updated versions.

## Scope

- [x] This PR is focused addressing the syncserver docker image.

Co-authored-by: Abdo <abdo@abdnh.net>
2026-06-19 18:10:39 +03:00
Konstantin Tutsch
daad13f01f fix: failing syncserver Docker build (#5021)
## Summary / motivation (required)

This PR fixes Docker Image builds for syncserver failing due to a Rust
version being used in both available Dockerfiles that is no longer
supported by the two dependencies `time@0.3.47` and `time-core@0.1.8`.

## Issue

Fixes #5022 

## Steps to reproduce (required, use N/A if not applicable)

1. `cd docs/syncserver`
2. `docker build -f Dockerfile --no-cache --build-arg ANKI_VERSION=26.05
-t anki-sync-server .`
3. Error (see issue)

## How to test (required)

1. `cd docs/syncserver`
2. `docker build -f Dockerfile --no-cache --build-arg ANKI_VERSION=26.05
-t anki-sync-server .`
3. run Docker image

## Scope

- [x] This PR is focused on one change (no unrelated edits).

Signed-off-by: Konstantin Tutsch <mail@konstantintutsch.com>
2026-06-19 18:06:47 +03:00
cypher
65f45ea87d 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/
2026-04-07 16:51:28 +03:00
Kolby Moroz Liebl
6427ff3db5 Fix dockerimage, by bumping rust version (#3993) 2025-05-15 16:09:27 +10:00
llama
d809ee92db Fix cargo ignoring lockfile when building syncserver image (#3856)
* pass --locked to cargo invocation

* update Dockerfile.distroless as well

Co-authored-by: Simon <8466614+SimonBaars@users.noreply.github.com>

---------

Co-authored-by: Simon <8466614+SimonBaars@users.noreply.github.com>
2025-03-14 17:04:56 +07:00
Omar Kohl
eaec53bfc4 Ignore SYNC_PORT and SYNC_BASE in syncserver Dockerfile (#3716)
Hardcode them to:

    SYNC_PORT=8080
    SYNC_BASE=/anki_data

If these env variables are passed into the container with different values,
they are ignored.

The reasons is if the user modifies SYNC_BASE they risk data loss since
anki-sync-server will no longer write data into the volume. If they change
SYNC_PORT they need to also change it when mapping this internal port to the
external port of the container, which could be confusing plus it has no benefit
to allow this since it's always possible to change the external port even if
the internal port is fixed to 8080 (e.g. `-p 1234:8080`).

In both cases there is no benefit to making these values configurable and there
are risks associated.

Unfortunately there is no easy way of implementing this for the
Dockerfile.distroless so it's up to the user not to modify these values.
2025-01-25 19:28:55 +11:00
Omar Kohl
71e2a6f782 Introduce PUID and PGID env variables to syncserver Dockerfile (#3714)
PUID and PGID are optional env variables to specify the user and group id of
the user that the anki-sync-server process should run with.

This gives more flexibility for solving permission problems with volumes and is
a common pattern for Docker images (e.g. see here:
https://docs.linuxserver.io/general/understanding-puid-and-pgid/)

The anki-sync-server process will write any files with the permissions of the
user it's running with, which can be a problem when you need to access those
files from outside the container or when they are being written into a bind
mount that is owned by a particular user on the host system.

To be able to implement this the entrypoint.sh needs to run as root (since it
needs to create a user and change file permissions). anki-sync-server then
needs to be started with the user 'anki', which is why the new dependency
'su-exec' is required. The user 'anki' and group 'anki-group' can no longer be
created at image build time because then their ids would be fixed.

Also update the build instructions to require building the Docker image inside
the directory where the Dockerfile resides since the build now needs to copy
the entrypoint.sh and it seems wrong the specify the path
docs/syncserver/entrypoint.sh inside the Dockerfile.
2025-01-25 18:19:38 +11:00
Omar Kohl
b189820218 Ensure data is stored in a volume in anki-sync-server Docker image (#3674)
Otherwise data would be lost by default when removing (or re-creating) a
container.

It would be possible to expose the default directory (e.g.
/home/anki/.syncserver) but it would be different for the two Dockerfiles and
less convenient for users of the Docker container to specify such a long path
when naming their volumes.

Setting the permissions is necessary since anki will be running with 'anki'
user permissions inside the container.
2025-01-10 21:42:55 +11:00
Omar Kohl
6f2c959dc3 replace localhost with 127.0.0.1 in syncserver Dockerfile (#3673)
* Add myself to CONTRIBUTORS file

* replace localhost with 127.0.0.1 in syncserver Dockerfile

The healthcheck was failing, presumably because localhost was resolving to ::1
(IPv6), as detailed in this issue: https://github.com/maildev/maildev/pull/500
2025-01-05 01:24:29 +03:00
Niclas Heinz
936e10bd76 update docker deps and docker docs (#3671)
* docs(docker): Change suggested version numbre

* deps(docker): Bump rust to 1.83.0 and alpine to 3.21.0

* deps(docker): Bump rust to 1.83.0

* CONTRIBUTORS: Add my name
2025-01-04 17:58:54 +03:00
Omar Kohl
7f12814bbe avoid warning by setting SYNC_PORT as ARG in Dockerfile (#3675)
* Add myself to CONTRIBUTORS file

* avoid warning by setting SYNC_PORT as ARG in Dockerfile

    1 warning found (use docker --debug to expand):
    - UndefinedVar: Usage of undefined variable '$SYNC_PORT'
2025-01-04 17:51:43 +03:00
Jean Khawand
15fde04264 Bump rust base image 1.80.1 to 1.82.0 (#3587) 2024-11-18 23:42:24 +10:00
Jean Khawand
83fe301c1c Add distroless Dockerfile and implement internal health check (#3366)
- rslib(http_server): add `is_running()` method
- rslib(sync): introduce `--healthcheck` argument for health probe in distroless
- doc(syncserver): add table comparing Dockerfile and Dockerfile.distroless
- Expand cross-platform support with distroless
- add `Dockerfile.distroless`

- Dockerfile: bump rust `1.79` to `1.80.1`
- Dockerfile: bump alpine `3.20` to `3.20.2`

Note: Implemented an internal health check because distroless images do not include curl, which is used to reduce image size and attack surface. For more details, see https://blog.sixeyed.com/docker-healthchecks-why-not-to-use-curl-or-iwr/
https://github.com/GoogleContainerTools/distroless

fix: failed: check:format:rust

typo

remove extra space

fix failed:check:format:rust

update doc

fetch `host` and `port` using envy

fix: failed: check:format:rust

Update doc + add dockerignore

- dockerignore: This helps avoid sending unwanted files and directories to the builder
- add new line
- I am still experimenting cross platform compilation, I am getting
4.337 From https://github.com/ankitects/rust-url
4.337  * [new ref]         bb930b8d089f4d30d7d19c12e54e66191de47b88 -> refs/commit/bb930b8d089f4d30d7d19c12e54e66191de47b88
4.397 error: failed to get `percent-encoding-iri` as a dependency of package `anki v0.0.0 (/app/rslib)`

still checking what could be the issue

fix: failed: check:format:dprint
2024-08-29 17:05:33 +07:00
Jean Khawand
56a085bc21 Update base images and introduce health endpoint (#3273)
* Update base images and introduce health endpoint

sync-server: introduce `/health` endpoint to check if the service is reachable.

bump(alpine): bump alpine base image from `3.19` to `3.20`

bump(rust): bump rust-alpine build image from `1.76` to `1.79`

* fix cargo fmt

* add allow clippy::extra_unused_type_parameters

* Remove unused type param (dae)

* Route /health directly (dae)

* Fix for latest axum (dae)
2024-07-10 20:35:21 +07:00
Jean Khawand
a694889bca 🐬Containerize anki-sync-server (#3036)
* 🐬Containerize anki-sync-server

* rename directory to syncserver

* update contributors

* fix format

* format README

* - make ANKI_VERSION mandatory
- remove SYNC_USERS and stick unique vars
- update doc

* update doc

* update doc

* - remove hardcoded ANKI_VERSION arg
- update readme
2024-03-01 15:15:02 +07:00