diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..3f9e4db --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,44 @@ +on: + push: + pull_request: + release: + types: [published] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout repository and submodules + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up QEMU + if: ${{ inputs.platforms != 'linux/amd64' }} + uses: docker/setup-qemu-action@v2 + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ format('ghcr.io/{0}', github.repository) }} + tags: | + type=semver,pattern=v{{major}} + type=semver,pattern=v{{major}}.{{minor}} + type=ref,event=branch + type=ref,event=tag + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}} + platforms: linux/amd64 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..89034e8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.10-slim + +COPY src /src +RUN cd /src \ +&& pip install -r requirements.txt \ +&& pip install -e . + +COPY src/ankisyncd /ankisyncd +COPY src/ankisyncd_cli /ankisyncd_cli +COPY src/ankisyncd.conf /ankisyncd.conf +RUN sed -i -e '/data_root =/ s/= .*/= \/data\/collections/' /ankisyncd.conf \ + && sed -i -e '/auth_db_path =/ s/= .*/= \/data\/auth\.db/' /ankisyncd.conf \ + && sed -i -e '/session_db_path =/ s/= .*/= \/data\/session.db/' /ankisyncd.conf \ + && cat /ankisyncd.conf + +#see https://github.com/ankicommunity/anki-sync-server/issues/139 +ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python + +CMD ["python", "-m", "ankisyncd"]