diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9df682c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +# Ignore everything +* + +# But not these files... +!README.md +!stitching/ +!pyproject.toml +!setup.cfg diff --git a/.github/workflows/docker-build-and-publish.yml b/.github/workflows/docker-build-and-publish.yml new file mode 100644 index 0000000..688d827 --- /dev/null +++ b/.github/workflows/docker-build-and-publish.yml @@ -0,0 +1,34 @@ +name: Publish Docker image + +on: + release: + types: [published] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: openstitching/stitch + + - name: Build and push Docker image + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }}, latest + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..10b9008 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM python:3.11 + +RUN mkdir /stitching +COPY . /stitching + +# build and install stitching package +WORKDIR /stitching +RUN pip install build +# we use opencv headless within docker, otherwise we get errors +RUN sed -i 's/opencv-python/opencv-python-headless/g' setup.cfg +RUN python -m build +RUN pip install ./dist/stitching-*.whl + +# compile largestinteriorrectangle (JIT) +RUN python -c "import largestinteriorrectangle" + +# provide the entrypoint, users need to mount a volume to /data +WORKDIR /data +ENTRYPOINT ["stitch"] +CMD ["-h"] diff --git a/README.md b/README.md index 64ebe69..46247e1 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ pip install stitching ## Usage +### Python CLI + The command line interface ([cli](https://github.com/lukasalexanderweber/stitching/tree/main/stitching/cli/stitch.py)) is available after installation @@ -41,6 +43,21 @@ Enable verbose mode with `stitch * -v`. This will create a folder where all intermediate results are stored so that you can find out where there are problems with your images, if any +### Docker CLI + +If you are familiar with Docker and don't feel like +setting up Python and an environment, you can also use the +[openstitching/stitch](https://hub.docker.com/r/openstitching/stitch) +Docker image + +`docker container run --rm -v +/path/to/data:/data openstitching/stitch:{version} -h` + +You can use the CLI as described above +(read "current directory" as "/data directory") + +### Python Script + You can also use the Stitcher class in your script ```python diff --git a/setup.cfg b/setup.cfg index 509dbc1..611fda7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,7 +7,7 @@ long_description_content_type = text/markdown author = Lukas Weber author_email = l.a.weber@outlook.de license = Apache License 2.0 -license_file = LICENSE +license_files = LICENSE platforms = any classifiers = Programming Language :: Python :: 3 :: Only