Anki/docs/syncserver/Dockerfile
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

42 lines
1 KiB
Docker

FROM rust:1.83.0-alpine3.20 AS builder
ARG ANKI_VERSION
RUN apk update && apk add --no-cache build-base protobuf && rm -rf /var/cache/apk/*
RUN cargo install --git https://github.com/ankitects/anki.git \
--tag ${ANKI_VERSION} \
--root /anki-server \
anki-sync-server
FROM alpine:3.21.0
ARG SYNC_PORT=8080
RUN adduser -D -h /home/anki anki
RUN mkdir -p /anki_data && chown -R anki /anki_data
COPY --from=builder /anki-server/bin/anki-sync-server /usr/local/bin/anki-sync-server
RUN apk update && apk add --no-cache bash && rm -rf /var/cache/apk/*
USER anki
ENV SYNC_PORT=${SYNC_PORT}
ENV SYNC_BASE=/anki_data
EXPOSE ${SYNC_PORT}
CMD ["anki-sync-server"]
# This health check will work for Anki versions 24.08.x and newer.
# For older versions, it may incorrectly report an unhealthy status, which should not be the case.
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget -qO- http://127.0.0.1:${SYNC_PORT}/health || exit 1
VOLUME /anki_data
LABEL maintainer="Jean Khawand <jk@jeankhawand.com>"