From fb670c64a69e4225742e88c5e8df0b5a694d0fae Mon Sep 17 00:00:00 2001 From: Lorenz Schmid Date: Mon, 2 Sep 2024 11:45:54 +0200 Subject: [PATCH] Initial commit --- Dockerfile | 25 +++++++++++++++++++++ LICENSE | 21 +++++++++++++++++ README.md | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bb21957 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# Use an official Python runtime as a parent image +FROM python:3.9-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the current directory contents into the container at /app +COPY . /app + +# Install the Anki sync server +RUN pip install anki + +# Set environment variables for the sync server (do not change) +ENV SYNC_BASE=/data +ENV SYNC_HOST=0.0.0.0 +ENV SYNC_PORT=8080 + +# Create the data directory +RUN mkdir -p /data + +# Expose the port the sync server runs on +EXPOSE 8080 + +# Run the sync server +CMD ["python", "-m", "anki.syncserver"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bd6a95d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Lorenz Schmid + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..dd1c6db --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +# Anki Sync Server Docker Container + +This docker container simply wraps the official minimal sync server based on Python. More information can be found in the [official documentation](https://docs.ankiweb.net/sync-server.html). + + +## Configuration + +The docker container uses the same environmental variable as described in the [official documentation](https://docs.ankiweb.net/sync-server.html). Some meaningful defaults are set. One might want to change the following environmental variables: + +- `SYNC_USER1`: The username and password for the first user in the format `user:password`. + + +## Running the Docker Container + +To start the Anki sync server in a Docker container: + +```sh +docker run \ + -d \ + --name anki-syncserver \ + -p 8080:8080 \ + -v ./data:/data \ + -e SYNC_USER1=user:password \ + ghcr.io/lorenzschmid/anki-syncserver +``` + +- `-d`: Runs the container in detached mode. +- `--name`: Assigns a name to the container (`anki-syncserver`). +- `-p 8080:8080`: Maps port `8080` on the host to port `8080` in the container. +- `-v ./data:/data`: Mounts the host directory `./data` to the container’s `/data` directory for data persistence. +- `-e SYNC_USER1=user:password`: Sets the `SYNC_USER1` environment variable to configure the sync server’s username and password. + +or via docker compose: + +```yaml +version: '3.8' + +services: + anki-syncserver: + image: ghcr.io/lorenzschmid/anki-syncserver + container_name: anki-syncserver + environment: + SYNC_USER1: "user:password" # Replace with your desired username:password + ports: + - "8080:8080" + volumes: + - "./data:/data" + restart: unless-stopped +``` + + +## Building the Docker Image Locally + +1. Clone this Repository: + ```sh + git clone https://github.com/lorenzschmid/anki-syncserver.git + cd anki-syncserver + ``` + +2. Build the Docker Image: + Run the following command in the directory containing your `Dockerfile`: + ```sh + docker build -t anki-syncserver . + ``` + + This command builds the Docker image and tags it as `anki-syncserver`.