diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a2bd9a..f6f1e61 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -164,3 +164,36 @@ jobs: files: 'dify*' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build-and-push-image: + name: Push Docker image to Github registry (ghcr.io) + runs-on: ubuntu-latest + needs: [check, test, lints] + if: startsWith(github.ref, 'refs/tags/') + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ghcr.io/${{ github.repository }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b5eb568 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM rust:1 as builder +WORKDIR /usr/src/dify +COPY Cargo.toml . +COPY ./src ./src +RUN cargo install --path . + +FROM debian:buster-slim +RUN apt-get update && apt-get install && rm -rf /var/lib/apt/lists/* +COPY --from=builder /usr/local/cargo/bin/dify /usr/local/bin/dify +WORKDIR /mnt/dify +ENTRYPOINT ["dify"] diff --git a/README.md b/README.md index 22fd6f5..a32d4ba 100644 --- a/README.md +++ b/README.md @@ -45,15 +45,24 @@ Download the binaries for your platform from [release](https://github.com/jihchi Please refer to [`dify-bin`](https://github.com/jihchi/dify-bin) npm package, it is a node.js wrapper for dify executable file: ```sh -$ npm install -g dify-bin # or `yarn global add dify-bin` -$ dify --help +npm install -g dify-bin # or `yarn global add dify-bin` +dify --help ``` ## Usage ```sh -$ dify left.jpg right.jpg -# check out diff.png if it is different +dify left.jpg right.jpg +``` + +Checkout `diff.png` if `a.jpg` and `b.jpg` are different. + +For more details, see `dify --help`. + +### Docker + +```sh +docker run -v $(pwd):/mnt/dify ghcr.io/jihchi/dify left.jpg right.jpg ``` ## Benchmarks @@ -61,7 +70,7 @@ $ dify left.jpg right.jpg > Test data is coming from [mtrKovalenko/odiff](https://github.com/dmtrKovalenko/odiff/tree/main/images) ```sh -$ hyperfine \ +hyperfine \ --warmup 1 \ --ignore-failure \ --export-markdown bench-dify.md \