add Dockerimage (#152)

* add Dockerfile

* Create docker.yml

* Update docker.yml

* Update docker.yml

* Update docker.yml

* Update docker.yml

* Update docker.yml

* Update docker.yml

* Update docker.yml

* hardcode python version

* install rustup

* Revert "install rustup"

This reverts commit 5f701ee084713bb633c7e840523574d96fa9191e.

* Update docker.yml

* Update docker.yml
This commit is contained in:
LuckyTurtleDev 2023-07-14 18:10:16 +02:00 committed by GitHub
parent 7532c960f2
commit 86ba071b6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 0 deletions

44
.github/workflows/docker.yml vendored Normal file
View File

@ -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

19
Dockerfile Normal file
View File

@ -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"]