diff --git a/.github/workflows/pushonrelease.yaml b/.github/workflows/pushonrelease.yaml new file mode 100644 index 0000000..cdb708d --- /dev/null +++ b/.github/workflows/pushonrelease.yaml @@ -0,0 +1,39 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +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: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: my-docker-hub-namespace/my-docker-hub-repository + + - name: Build and push Docker image + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + file: ./Dockerfile + push: true + tags: | + ghcr.io/${{ steps.meta.outputs.tags }} + ghcr.io/${{ github.repository }}:latest + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 0182438..3522d79 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,7 @@ -FROM python:3.9 +FROM python:3.12.5-slim -# download this https://github.com/danielgatis/rembg/releases/download/v0.0.0/u2net.onnx -# copy model to avoid unnecessary download -COPY u2net.onnx /home/.u2net/u2net.onnx +RUN apt update && apt install wget -y +RUN mkdir /root/.u2net && wget -O /root/.u2net/u2net.onnx https://github.com/danielgatis/rembg/releases/download/v0.0.0/u2net.onnx WORKDIR /app @@ -14,4 +13,4 @@ COPY . . EXPOSE 5100 -CMD ["python", "app.py"] \ No newline at end of file +CMD ["python", "app.py"] diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..7f81d7f --- /dev/null +++ b/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash +docker compose down +docker image rm ghcr.io/101br03k/rembg:v1.0-pv-3.12.5-slim +docker build . -t ghcr.io/101br03k/rembg:v1.0-pv-3.12.5-slim +docker compose up -d diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..10c137a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +version: "3.8" +services: + rembg: + image: ghcr.io/101br03k/rembg:v1.0-pv-3.12.5-slim + restart: unless-stopped + ports: + - 5100:5100 + container_name: re\mbg + network_mode: bridge diff --git a/templates/index.html b/templates/index.html index e4d7479..58c126d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,7 +1,7 @@ - ✂️ rmbg + ✂️ rembg