Skip to content

Commit

Permalink
Containerize dify (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
jihchi authored Aug 15, 2021
1 parent d1d7dab commit bb92a1f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 5 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,32 @@ 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

> 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 \
Expand Down

0 comments on commit bb92a1f

Please sign in to comment.