From 1c42a4847cf9ef0b5e1571817528945e3625c392 Mon Sep 17 00:00:00 2001
From: A3 <59868436+101br03k@users.noreply.github.com>
Date: Mon, 18 Mar 2024 21:17:32 +0100
Subject: [PATCH 1/4] moved to python slim
saves 1gb on image
---
Dockerfile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 0182438..c7edc16 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM python:3.9
+FROM python:3.12.2-slim
# download this https://github.com/danielgatis/rembg/releases/download/v0.0.0/u2net.onnx
# copy model to avoid unnecessary download
@@ -14,4 +14,4 @@ COPY . .
EXPOSE 5100
-CMD ["python", "app.py"]
\ No newline at end of file
+CMD ["python", "app.py"]
From 38a86f0c40c916c3e50745b1eab475622aa47109 Mon Sep 17 00:00:00 2001
From: A3 <59868436+101br03k@users.noreply.github.com>
Date: Mon, 18 Mar 2024 21:19:00 +0100
Subject: [PATCH 2/4] added pr3 on codediodeio/rembg-webapp-tutorial
https://github.com/codediodeio/rembg-webapp-tutorial/pull/3
---
templates/index.html | 1 +
1 file changed, 1 insertion(+)
diff --git a/templates/index.html b/templates/index.html
index e4d7479..7d4c798 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -59,6 +59,7 @@
rmbg
});
dropZone.addEventListener("dragover", function (e) {
+ e.preventDefault();
this.classList.add("dragover");
});
From 2bc6949d7772332816c8ad30461d485de8e8eb32 Mon Sep 17 00:00:00 2001
From: 101br03k
Date: Sat, 17 Aug 2024 18:52:58 +0000
Subject: [PATCH 3/4] updated python version
---
.github/workflows/pushonrelease.yaml | 45 ++++++++++++++++++++++++++++
Dockerfile | 7 ++---
build.sh | 5 ++++
docker-compose.yml | 9 ++++++
templates/index.html | 2 +-
5 files changed, 63 insertions(+), 5 deletions(-)
create mode 100644 .github/workflows/pushonrelease.yaml
create mode 100755 build.sh
create mode 100644 docker-compose.yml
diff --git a/.github/workflows/pushonrelease.yaml b/.github/workflows/pushonrelease.yaml
new file mode 100644
index 0000000..f393a64
--- /dev/null
+++ b/.github/workflows/pushonrelease.yaml
@@ -0,0 +1,45 @@
+# 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: 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: 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 }}
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index c7edc16..3522d79 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,8 +1,7 @@
-FROM python:3.12.2-slim
+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
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 7d4c798..58c126d 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,7 +1,7 @@
- ✂️ rmbg
+ ✂️ rembg