Skip to content

Commit

Permalink
feat: Add ANKISYNCD_COMMIT as a build arg (#45)
Browse files Browse the repository at this point in the history
* add ANKISYNCD_COMMIT
This adds the ability to checkout a specific commit of anki-sync-server as well as specify the version of the image to be built.

* feat: Add ANKISYND_COMMIT as a image label

---------

Co-authored-by: Vikash Kothary <[email protected]>
  • Loading branch information
senorsmile and VikashKothary authored Apr 17, 2024
1 parent 3424783 commit 2218ed5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
### ANKISYNCD_SESSION_MANAGER
### ANKISYNCD_USER_MANAGER
### ANKISYNCD_COLLECTION_WRAPPER
### ANKISYNCD_COMMIT=e719131720151b51f14242ff7cf898916e3b074c

## Djankiserv
### DJANKISERV_VARS_SOURCED="yes"
Expand Down Expand Up @@ -41,4 +42,4 @@
## Make
AWK=awk
BASH=bash
DOCKER_COMPOSE=docker-compose
DOCKER_COMPOSE=docker-compose
5 changes: 4 additions & 1 deletion services/anki-sync-server/images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ WORKDIR ${ANKISYNCD_ROOT}

COPY bin/download-release.sh ./bin/download-release.sh

ARG ANKISYNCD_COMMIT='latest'
LABEL ANKISYNCD_COMMIT=${ANKISYNCD_COMMIT}

ARG PYTHONUSERBASE
RUN sh ./bin/download-release.sh && \
pip3 install --upgrade pip && \
pip3 install --user -r ./release/requirements.txt
pip3 install --user -r ./release/requirements.txt

# -- DEPLOYER --
FROM python:3.9-slim-buster
Expand Down
9 changes: 8 additions & 1 deletion services/anki-sync-server/images/bin/download-release.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
#!/bin/sh
# file: download-release.sh

set -eu

mkdir -p release

cd release

git clone https://github.com/ankicommunity/anki-sync-server

if [ "${ANKISYNCD_COMMIT}" != 'latest' ]; then
cd anki-sync-server
git checkout "${ANKISYNCD_COMMIT}"
cd ..
fi

mv anki-sync-server/src/* .

rm -rf anki-sync-server

cd ..
cd ..
3 changes: 2 additions & 1 deletion services/anki-sync-server/images/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ services:
- ANKISYNCD_BASE_URL=${ANKISYNCD_BASE_URL:-/sync/}
- ANKISYNCD_BASE_MEDIA_URL=${ANKISYNCD_BASE_MEDIA_URL:-/msync/}
- ANKISYNCD_AUTH_DB_PATH=${ANKISYNCD_AUTH_DB_PATH:-./auth.db}
- ANKISYNCD_SESSION_DB_PATH=${ANKISYNCD_SESSION_DB_PATH:-./session.db}
- ANKISYNCD_SESSION_DB_PATH=${ANKISYNCD_SESSION_DB_PATH:-./session.db}
- ANKISYNCD_COMMIT=${ANKISYNCD_COMMIT:-latest}

0 comments on commit 2218ed5

Please sign in to comment.