diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..8a99e2a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 + +updates: + - package-ecosystem: docker + directory: / + schedule: + interval: daily diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml new file mode 100644 index 0000000..d358beb --- /dev/null +++ b/.github/workflows/docker-build-push.yml @@ -0,0 +1,116 @@ +name: Docker build and publish +run-name: Run for ${{ github.ref_name }} (${{github.ref_type}}, triggered by ${{ github.event_name }}) + +on: + workflow_dispatch: + push: + branches: + # Run on every branch + - '**' + # Except branches beginning with: + - '!fail/**' + - '!dead-end/**' + - '!trash/**' + - '!dependabot/**' # avoid running Workflow twice, because Dependabot creates a branch ("push" event) and a pull request) + tags: + - '**' + pull_request: + types: [opened, synchronize, reopened] + +env: + TARGET_IMAGE: dersimn/gifify + +jobs: + build: + name: Build ${{ matrix.flavor }} + runs-on: ubuntu-latest + strategy: + matrix: + include: + # - flavor: alpine # Name e.g. some different base-image + # # The flavor with "default-flavor: true" additionally gets the suffix-less Docker tag, e.g. "mybranch-myflavor" and additionally only "mybranch" while all other flavors only have their usual "mybranch-myotherflavor". + # default-flavor: false + # dockerfile: ./Dockerfile-alpine # Dockerfile to use with this flavor + # build-platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x + - flavor: alpine + default-flavor: true + dockerfile: ./Dockerfile-alpine + build-platforms: linux/amd64,linux/arm64/v8 + - flavor: debian + dockerfile: ./Dockerfile-debian + build-platforms: linux/amd64,linux/arm64/v8 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.TARGET_IMAGE }} + flavor: | + latest=false + tags: | + # Latest tag only for default flavor & default branch + type=raw,value=latest,enable=${{ format('refs/heads/{0}', github.event.repository.default_branch) == github.ref && matrix.default-flavor || 'false' }} + # plain flavor string on default branch + type=raw,value=${{ matrix.flavor }},enable={{is_default_branch}} + # Branch name WITHOUT suffix for default flavor + #type=ref,event=branch,enable=${{ matrix.default-flavor || 'false' }} + # Branch name WITH suffix for every branch & flavor + type=ref,event=branch,suffix=-${{ matrix.flavor }} + # Git Tag WITHOUT suffix for default flavor + #type=ref,event=tag,enable=${{ matrix.default-flavor || 'false' }} + # Git Tag WITH suffix for every tag & flavor + type=ref,event=tag,suffix=-${{ matrix.flavor }} + # Commit short SHA WITHOUT suffix for default flavor + #type=sha,enable=${{ matrix.default-flavor || 'false' }} + # Commit short SHA WITH suffix every flavor: sha-ad132f5-myflavor + #type=sha,suffix=-${{ matrix.flavor }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + if: github.event_name != 'pull_request' + with: + username: ${{ vars.DOCKERHUB_USERNAME || github.repository_owner }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + push: ${{ github.event_name != 'pull_request' }} + context: . + file: ${{ matrix.dockerfile }} + platforms: ${{ matrix.build-platforms }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Summary + run: | + echo "Pushed Docker Tags:" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo '${{ steps.meta.outputs.tags }}' >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + + dependabot-auto-merge: + needs: build + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + permissions: + pull-requests: write + contents: write + steps: + - name: Enable auto-merge for Dependabot PRs + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + # Using GITHUB_TOKEN __won't__ trigger following Workflows + # see: https://github.com/orgs/community/discussions/55906 + #GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index efac868..0000000 --- a/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM ubuntu:14.04 - -RUN apt-get update -RUN apt-get -y install software-properties-common -RUN add-apt-repository ppa:jon-severinsson/ffmpeg -RUN apt-get update -RUN apt-get -y install ffmpeg unzip imagemagick curl - -# install fork of gifsicle with better lossless gif support -RUN curl -OJL https://github.com/pornel/giflossy/releases/download/lossy%2F1.82.1/gifsicle-1.82.1-lossy.zip -RUN unzip gifsicle-1.82.1-lossy.zip -d gifsicle -RUN mv gifsicle/linux/gifsicle-debian6 /usr/local/bin/gifsicle - -# install iojs -RUN curl -OJL https://iojs.org/dist/v1.2.0/iojs-v1.2.0-linux-x64.tar.xz -RUN tar xf iojs-v1.2.0-linux-x64.tar.xz -RUN ln -s /iojs-v1.2.0-linux-x64/bin/node /usr/local/bin/node -RUN ln -s /iojs-v1.2.0-linux-x64/bin/iojs /usr/local/bin/iojs -RUN ln -s /iojs-v1.2.0-linux-x64/bin/npm /usr/local/bin/npm - -# install gifify -RUN npm i gifify -g - -# run gifify in /data (requires user to mount their source folder in /data) -WORKDIR /data - -ENTRYPOINT ["gifify"] diff --git a/Dockerfile-alpine b/Dockerfile-alpine new file mode 100644 index 0000000..b1e189b --- /dev/null +++ b/Dockerfile-alpine @@ -0,0 +1,13 @@ +FROM node:24.1.0-alpine3.20@sha256:8fe019e0d57dbdce5f5c27c0b63d2775cf34b00e3755a7dea969802d7e0c2b25 + +RUN apk add --no-cache \ + gifsicle \ + ffmpeg \ + imagemagick + +# install gifify +RUN npm i -g gifify + +# run gifify in /data (requires user to mount their source folder in /data) +WORKDIR /data +ENTRYPOINT ["gifify"] diff --git a/Dockerfile-debian b/Dockerfile-debian new file mode 100644 index 0000000..371619e --- /dev/null +++ b/Dockerfile-debian @@ -0,0 +1,14 @@ +FROM node:25.6.0-bookworm-slim@sha256:3746b7c78e343062cbad1a1a9f22e582e2aaeda5b183b7050b5831e22f988730 + +RUN apt-get update && \ + apt-get install -y \ + gifsicle \ + ffmpeg \ + imagemagick + +# install gifify +RUN npm i -g gifify + +# run gifify in /data (requires user to mount their source folder in /data) +WORKDIR /data +ENTRYPOINT ["gifify"] diff --git a/README.md b/README.md index 307b1b3..b9b8c75 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,65 @@ # gifify-docker -A docker container for [gifify](https://github.com/vvo/gifify) +A docker container for [gifify](https://github.com/vvo/gifify). Based on the work of [maxogden](https://github.com/maxogden/gifify-docker) and [STRML](https://github.com/STRML/gifify-docker). -![docker-badge](http://dockeri.co/image/maxogden/gifify) +![docker-badge](http://dockeri.co/image/dersimn/gifify) -## installation +# Installation 1. install docker -2. run `docker run -it --rm -v $(pwd):/data maxogden/gifify source.mov -o output.gif` +2. run `docker run -it --rm -v $(pwd):/data dersimn/gifify source.mov -o output.gif` -When you run `docker run maxogden/gifify` it executes the `gifify` command in `/data` inside the docker ubuntu VM, so in order for this to work you must mount your current working directory as `/data` in the volume. This is what `-v $(pwd):/data` does in the command above. +When you run `docker run dersimn/gifify` it executes the `gifify` command in `/data` inside the docker ubuntu VM, so in order for this to work you must mount your current working directory as `/data` in the volume. This is what `-v $(pwd):/data` does in the command above. +You could also specify this command as an alias in your `.bashrc` file, for e.g.: + + alias gifify='docker run -it --rm -v $(pwd):/data dersimn/gifify' + +and use it like + + gifify source.mov -o output.gif + + +## Usage Examples + + docker run -it --rm -v "$(pwd)":/data dersimn/gifify source.mov -o output.gif + +Fit video in a 350x350 rectangle and don't scale up if it's smaller: + + docker run -it --rm -v "$(pwd)":/data dersimn/gifify source.mov -o output.gif --resize w=350:h=350:force_original_aspect_ratio=decrease + + +# Build + +## Docker build + + docker build -f Dockerfile-debian -t dersimn/gifify . + docker build -f Dockerfile-alpine -t dersimn/gifify:alpine . + +## buildx + +## buildx + + docker buildx create --name mybuilder + docker buildx use mybuilder + + docker buildx build \ + -f Dockerfile-debian \ + --platform linux/amd64,linux/arm64/v8 \ + -t dersimn/gifify:debian \ + --push \ + . + + docker buildx build \ + -f Dockerfile-alpine \ + --platform linux/amd64,linux/arm64/v8 \ + -t dersimn/gifify \ + -t dersimn/gifify:alpine \ + --push \ + . + +## GitHub Actions + +Provide secrets: + + gh secret set PERSONAL_ACCESS_TOKEN --body '' --app dependabot + gh secret set DOCKERHUB_TOKEN --body '' diff --git a/gasket.json b/gasket.json deleted file mode 100644 index 5b6a3dd..0000000 --- a/gasket.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "build": ["docker build --tag=maxogden/gifify ."] -} \ No newline at end of file