Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzschmid committed Sep 13, 2024
0 parents commit fb670c6
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit fb670c6

Please sign in to comment.