Skip to content

Commit

Permalink
provide stitch cli via docker (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasalexanderweber authored Oct 18, 2023
1 parent cf8f3e7 commit 50fbb42
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Ignore everything
*

# But not these files...
!README.md
!stitching/
!pyproject.toml
!setup.cfg
34 changes: 34 additions & 0 deletions .github/workflows/docker-build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 50fbb42

Please sign in to comment.