From 9486963cc7d296cca57c7414579714440bfb2901 Mon Sep 17 00:00:00 2001
From: Ada <ada@noreply.localhost>
Date: Sat, 30 Sep 2023 15:45:29 +0000
Subject: [PATCH 1/5] add: readme

---
 README.md | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 README.md

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..142359e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,11 @@
+# A code share paste
+
+## Run
+Require redis and python, install python requirements with `pip install -r requirements.txt`. Run with `flask --app paste run` (add `--debug` for devlopement)
+You can configure with multiple environnement variables.
+- PASTE_REDIS_HOST: redis host (default localhost)
+- PASTE_REDIS_PORT: redis port (default 6379)
+- PASTE_REDIS_USER: redis username (default none)
+- PASTE_REDIS_PASSWORD: redis password (default none)
+- PASTE_URL_LENGTH: length for url used by paste
+- PASTE_SECRET_KEY: secret key for flask, don't use the default value (generate a safe value with `openssl rand -hex 16`).
-- 
2.49.1


From 79932227151570fcc21c55aaf3f1364dd2d8ed1d Mon Sep 17 00:00:00 2001
From: Ada <ada@noreply.localhost>
Date: Sat, 30 Sep 2023 16:43:23 +0000
Subject: [PATCH 2/5] fix(backend: config): bad variable name for redis port

---
 paste/config.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/paste/config.py b/paste/config.py
index 9039716..7c1a57b 100755
--- a/paste/config.py
+++ b/paste/config.py
@@ -2,7 +2,7 @@
 from os import getenv
 
 REDIS_HOST = getenv("PASTE_REDIS_HOST") or "localhost"
-REDIS_PORT = getenv("PASTE_REDIS_HOST") or "6379"
+REDIS_PORT = getenv("PASTE_REDIS_PORT") or "6379"
 REDIS_USER = getenv("PASTE_REDIS_USER") or None
 REDIS_PASSWORD = getenv("PASTE_REDIS_PASSWORD") or None
 URL_LENGTH = getenv("PASTE_URL_LENGTH") or 4
-- 
2.49.1


From 95614a9208cf79a649fef1e630b95baeec5d911a Mon Sep 17 00:00:00 2001
From: Ada <ada@gnous.eu>
Date: Tue, 26 Sep 2023 16:12:57 +0200
Subject: [PATCH 3/5] remove(lint): deprecated format option

---
 pyproject.toml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index 006ee48..20163ed 100755
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -59,7 +59,6 @@ exclude = [
     "instances",
     "schema.sql"
 ]
-format = "grouped"
 
 [tool.isort]
 profile = "black"
-- 
2.49.1


From 9155206b5c7dd5d0735dc994d915d3ee961a9260 Mon Sep 17 00:00:00 2001
From: Ada <ada@gnous.eu>
Date: Sun, 1 Oct 2023 13:02:23 +0200
Subject: [PATCH 4/5] add: docker support

---
 Dockerfile             | 11 +++++++++++
 docker-compose-dev.yml | 13 +++++++++++++
 docker-compose.yml     | 13 +++++++++++++
 paste/home.py          |  9 +++++++++
 4 files changed, 46 insertions(+)
 create mode 100644 Dockerfile
 create mode 100644 docker-compose-dev.yml
 create mode 100644 docker-compose.yml

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..2f3bc82
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,11 @@
+FROM python:3.11-slim
+WORKDIR /paste
+COPY requirements.txt requirements.txt
+COPY paste ${WORKDIR}
+
+RUN apt update && apt install -y wget && apt -y clean
+RUN pip install -r requirements.txt
+
+EXPOSE 5000
+
+CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
\ No newline at end of file
diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml
new file mode 100644
index 0000000..df41403
--- /dev/null
+++ b/docker-compose-dev.yml
@@ -0,0 +1,13 @@
+services:
+  paste:
+    build: .
+    ports:
+      - "5000:5000"
+    environment:
+      PASTE_REDIS_HOST: "redis"
+    healthcheck:
+      test: [ 'CMD', 'wget', '-q', '--spider', 'http://localhost/health']
+  redis:
+    image: "redis:7.0"
+    healthcheck:
+      test: [ 'CMD', 'redis-cli', 'ping' ]
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..a4bb79e
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,13 @@
+services:
+  paste:
+    build: git.gnous.eu/gnouseu/paste
+    ports:
+      - "5000:5000"
+    environment:
+      PASTE_REDIS_HOST: "redis"
+    healthcheck:
+      test: [ 'CMD', 'wget', '-q', '--spider', 'http://localhost/health']
+  redis:
+    image: "redis:7.0"
+    healthcheck:
+      test: [ 'CMD', 'redis-cli', 'ping' ]
diff --git a/paste/home.py b/paste/home.py
index 939b64b..5aa0b8a 100755
--- a/paste/home.py
+++ b/paste/home.py
@@ -87,3 +87,12 @@ def get_content(path: str) -> str:
         return render_template("content.html.j2")
 
     return abort(404)
+
+
+@home.route("/check")
+def health_check() -> str:
+    """
+    For verify if the app run.
+    :return: "ok".
+    """
+    return "ok"
-- 
2.49.1


From fb4dc235741caafba13194ccc0ad9586f17a9354 Mon Sep 17 00:00:00 2001
From: Ada <ada@gnous.eu>
Date: Sun, 1 Oct 2023 13:15:44 +0200
Subject: [PATCH 5/5] add(backend): health check

---
 paste/home.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/paste/home.py b/paste/home.py
index 5aa0b8a..f6c602d 100755
--- a/paste/home.py
+++ b/paste/home.py
@@ -89,7 +89,7 @@ def get_content(path: str) -> str:
     return abort(404)
 
 
-@home.route("/check")
+@home.route("/health")
 def health_check() -> str:
     """
     For verify if the app run.
-- 
2.49.1