Changed to docker image that builds from source
This commit is contained in:
parent
4a8c1de794
commit
3d0ec7f2f6
|
@ -1,59 +1,32 @@
|
|||
ARG ANKISYNCD_ROOT=/opt/ankisyncd
|
||||
ARG PYTHONUSERBASE=/opt/venv
|
||||
# Set the base image
|
||||
FROM rust:latest as builder
|
||||
|
||||
# -- BUILDER --
|
||||
FROM library/python:3.9-buster as builder
|
||||
# Install dependencies
|
||||
RUN apt-get update && apt-get install -y protobuf-compiler
|
||||
|
||||
ARG ANKISYNCD_ROOT
|
||||
WORKDIR ${ANKISYNCD_ROOT}
|
||||
# Build the Anki sync server
|
||||
WORKDIR /usr/src/ankisyncd
|
||||
RUN cargo install --git https://github.com/ankitects/anki.git --tag 2.1.66 anki-sync-server
|
||||
|
||||
COPY bin/download-release.sh ./bin/download-release.sh
|
||||
# Create a deploy image for smaller size
|
||||
FROM debian:bookworm-slim
|
||||
COPY --from=builder /usr/local/cargo/bin/anki-sync-server /usr/local/bin/
|
||||
|
||||
ARG PYTHONUSERBASE
|
||||
RUN sh ./bin/download-release.sh && \
|
||||
pip3 install --upgrade pip && \
|
||||
pip3 install --user -r ./release/requirements.txt
|
||||
# Set environment variables for the sync server
|
||||
ENV ANKISYNCD_DATA_ROOT=/data
|
||||
ENV ANKISYNCD_AUTH_DB_PATH=/data/auth.db
|
||||
ENV ANKISYNCD_SESSION_DB_PATH=/data/session.db
|
||||
ENV SYNC_BASE=/data
|
||||
|
||||
# -- DEPLOYER --
|
||||
FROM python:3.9-slim-buster
|
||||
# Create a directory for data
|
||||
VOLUME /data
|
||||
|
||||
# Copy Python dependencies
|
||||
ARG PYTHONUSERBASE
|
||||
ENV PYTHONUSERBASE=${PYTHONUSERBASE}
|
||||
COPY --from=builder ${PYTHONUSERBASE} ${PYTHONUSERBASE}
|
||||
# Expose the default port
|
||||
EXPOSE 27701
|
||||
|
||||
# Copy Anki Sync Server release and scripts
|
||||
ARG ANKISYNCD_ROOT
|
||||
COPY --from=builder ${ANKISYNCD_ROOT}/release ${ANKISYNCD_ROOT}
|
||||
WORKDIR ${ANKISYNCD_ROOT}
|
||||
# Copy the entrypoint script and make it executable
|
||||
COPY bin/entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
# Move ankisyncctl.py to the working directory and make it executable
|
||||
RUN mv /opt/ankisyncd/ankisyncd_cli/ankisyncctl.py /opt/ankisyncd/ankisyncctl.py && \
|
||||
chmod +x /opt/ankisyncd/ankisyncctl.py
|
||||
|
||||
# Create data volume.
|
||||
ARG ANKISYNCD_DATA_ROOT=/srv/ankisyncd
|
||||
VOLUME ${ANKISYNCD_DATA_ROOT}
|
||||
|
||||
# Set default environment variables.
|
||||
ARG ANKISYNCD_PORT=27701
|
||||
ARG ANKISYNCD_BASE_URL=/sync/
|
||||
ARG ANKISYNCD_BASE_MEDIA_URL=/msync/
|
||||
|
||||
ENV ANKISYNCD_HOST=0.0.0.0 \
|
||||
ANKISYNCD_PORT=${ANKISYNCD_PORT} \
|
||||
ANKISYNCD_DATA_ROOT=${ANKISYNCD_DATA_ROOT} \
|
||||
ANKISYNCD_BASE_URL=${ANKISYNCD_BASE_URL} \
|
||||
ANKISYNCD_BASE_MEDIA_URL=${ANKISYNCD_BASE_MEDIA_URL} \
|
||||
ANKISYNCD_AUTH_DB_PATH=/data/auth.db \
|
||||
ANKISYNCD_SESSION_DB_PATH=/data/session.db \
|
||||
ANKISYNCD_DATA_ROOT=/data
|
||||
|
||||
COPY bin/entrypoint.sh ./bin/entrypoint.sh
|
||||
|
||||
EXPOSE ${ANKISYNCD_PORT}
|
||||
|
||||
# TODO: Change to ENTRYPOINT. Currently CMD to allow shell access if needed.
|
||||
CMD ["/bin/sh", "./bin/entrypoint.sh"]
|
||||
|
||||
HEALTHCHECK --interval=60s --timeout=3s CMD python -c "import requests; requests.get('http://127.0.0.1:${ANKISYNCD_PORT}/')"
|
||||
# Set the entrypoint for the container
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/sh
|
||||
# file: download-release.sh
|
||||
|
||||
|
||||
mkdir -p release
|
||||
|
||||
cd release
|
||||
|
||||
git clone https://github.com/ankicommunity/anki-sync-server
|
||||
|
||||
mv anki-sync-server/src/* .
|
||||
|
||||
rm -rf anki-sync-server
|
||||
|
||||
cd ..
|
|
@ -1,15 +1,13 @@
|
|||
#!/bin/sh
|
||||
# file: entrypoint.sh
|
||||
#!/bin/bash
|
||||
|
||||
# if [ -f "/app/data/auth.db" ]; then
|
||||
# echo "auth.db found"
|
||||
# else
|
||||
# echo "Creating new authentication database: auth.db."
|
||||
# sqlite3 /app/data/auth.db 'CREATE TABLE auth (user VARCHAR PRIMARY KEY, hash VARCHAR)'
|
||||
# fi
|
||||
IFS=',' read -ra USER_ARRAY <<< "$SYNC_USERS"
|
||||
|
||||
# echo "Updating database schema"
|
||||
# python3 utils/migrate_user_tables.py
|
||||
for index in "${!USER_ARRAY[@]}"; do
|
||||
USER_PASS="${USER_ARRAY[index]}"
|
||||
export "SYNC_USER$((index+1))=$USER_PASS"
|
||||
done
|
||||
|
||||
# Now start the anki-sync-server
|
||||
echo "Starting anki sync server..."
|
||||
exec anki-sync-server
|
||||
|
||||
echo "Starting anki-sync-server"
|
||||
python3 -m ankisyncd
|
|
@ -6,8 +6,9 @@ services:
|
|||
- ANKISYNCD_DATA_ROOT=/data
|
||||
- ANKISYNCD_AUTH_DB_PATH=/data/auth.db
|
||||
- ANKISYNCD_SESSION_DB_PATH=/data/session.db
|
||||
- SYNC_USERS=${SYNC_USERS}
|
||||
ports:
|
||||
- "${ANKI_PORT}:27701"
|
||||
- "${ANKI_PORT}:8080"
|
||||
volumes:
|
||||
- "${ANKI_VOLUME_PATH}:/data"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user