From e9d14ac4171d3bb417ea705d6b31eb886b32ce95 Mon Sep 17 00:00:00 2001
From: Sheldan <5037282+Sheldan@users.noreply.github.com>
Date: Wed, 20 Dec 2023 21:04:35 +0100
Subject: [PATCH] [AB-xxx] refactoring rest-api to not be a maven project and
restructuring python tool file structure
---
deployment/installer/.env => .env | 0
.github/workflows/release.yml | 1 -
abstracto-application/pom.xml | 1 -
abstracto-application/rest-api/pom.xml | 38 ------------------
.../rest-api/src/main/assembly/assembly.xml | 19 ---------
deployment/installer/docker-compose.yaml | 9 -----
docker-compose.yaml | 14 +++++++
python/components/rest-api/docker/Dockerfile | 10 +++++
.../components/rest-api}/python/__init__.py | 0
.../rest-api}/python/base/__init__.py | 0
.../rest-api}/python/base/image_gen.py | 0
.../rest-api}/python/custom/__init__.py | 0
.../components/rest-api}/python/main.py | 0
.../rest-api/python/requirements.txt | 17 ++++++++
.../rest-api}/python/utils/__init__.py | 0
.../rest-api}/python/utils/flask_utils.py | 0
.../rest-api}/resources/img/semf_template.jpg | Bin
python/components/rest-api/wrapper/run.sh | 5 +++
.../installer/config-deployment/Dockerfile | 0
.../installer/config-deployment/__init__.py | 0
.../config-deployment/python/__init__.py | 0
.../python/liquibase_deploy.py | 0
.../config-deployment/python/main.py | 0
.../python/templates/liquibase.properties.j2 | 0
.../config-deployment/wrapper/deploy.sh | 0
.../installer/template-deployment/Dockerfile | 0
.../installer/template-deployment/__init__.py | 0
.../template-deployment/python/__init__.py | 0
.../template-deployment/python/main.py | 0
.../python/templates_deploy.py | 0
.../template-deployment/wrapper/deploy.sh | 0
31 files changed, 46 insertions(+), 68 deletions(-)
rename deployment/installer/.env => .env (100%)
delete mode 100644 abstracto-application/rest-api/pom.xml
delete mode 100644 abstracto-application/rest-api/src/main/assembly/assembly.xml
delete mode 100644 deployment/installer/docker-compose.yaml
create mode 100644 docker-compose.yaml
create mode 100644 python/components/rest-api/docker/Dockerfile
rename {abstracto-application/rest-api/src/main => python/components/rest-api}/python/__init__.py (100%)
rename {abstracto-application/rest-api/src/main => python/components/rest-api}/python/base/__init__.py (100%)
rename {abstracto-application/rest-api/src/main => python/components/rest-api}/python/base/image_gen.py (100%)
rename {abstracto-application/rest-api/src/main => python/components/rest-api}/python/custom/__init__.py (100%)
rename {abstracto-application/rest-api/src/main => python/components/rest-api}/python/main.py (100%)
create mode 100644 python/components/rest-api/python/requirements.txt
rename {abstracto-application/rest-api/src/main => python/components/rest-api}/python/utils/__init__.py (100%)
rename {abstracto-application/rest-api/src/main => python/components/rest-api}/python/utils/flask_utils.py (100%)
rename {abstracto-application/rest-api/src/main => python/components/rest-api}/resources/img/semf_template.jpg (100%)
create mode 100755 python/components/rest-api/wrapper/run.sh
rename {deployment => python/deployment}/installer/config-deployment/Dockerfile (100%)
rename {deployment => python/deployment}/installer/config-deployment/__init__.py (100%)
rename {deployment => python/deployment}/installer/config-deployment/python/__init__.py (100%)
rename {deployment => python/deployment}/installer/config-deployment/python/liquibase_deploy.py (100%)
rename {deployment => python/deployment}/installer/config-deployment/python/main.py (100%)
rename {deployment => python/deployment}/installer/config-deployment/python/templates/liquibase.properties.j2 (100%)
rename {deployment => python/deployment}/installer/config-deployment/wrapper/deploy.sh (100%)
rename {deployment => python/deployment}/installer/template-deployment/Dockerfile (100%)
rename {deployment => python/deployment}/installer/template-deployment/__init__.py (100%)
rename {deployment => python/deployment}/installer/template-deployment/python/__init__.py (100%)
rename {deployment => python/deployment}/installer/template-deployment/python/main.py (100%)
rename {deployment => python/deployment}/installer/template-deployment/python/templates_deploy.py (100%)
rename {deployment => python/deployment}/installer/template-deployment/wrapper/deploy.sh (100%)
diff --git a/deployment/installer/.env b/.env
similarity index 100%
rename from deployment/installer/.env
rename to .env
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 15d00b5e2..fc81ae57a 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -50,7 +50,6 @@ jobs:
path: ./deployment/installer/.env
- name: Push container
run: docker-compose build && docker-compose push
- working-directory: ./deployment/installer/
env:
REGISTRY_PREFIX: ${{ steps.dotenv.outputs.registry_prefix }}
VERSION: ${{ steps.dotenv.outputs.version }}
\ No newline at end of file
diff --git a/abstracto-application/pom.xml b/abstracto-application/pom.xml
index a8de11045..e51fab1f9 100644
--- a/abstracto-application/pom.xml
+++ b/abstracto-application/pom.xml
@@ -19,7 +19,6 @@
scheduling
documentation
bundle
- rest-api
diff --git a/abstracto-application/rest-api/pom.xml b/abstracto-application/rest-api/pom.xml
deleted file mode 100644
index 365ec13d1..000000000
--- a/abstracto-application/rest-api/pom.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
- 4.0.0
-
- dev.sheldan.abstracto
- abstracto-application
- 1.5.15-SNAPSHOT
-
-
- dev.sheldan.sissi.api
- rest-api
- pom
-
-
-
- org.apache.maven.plugins
- maven-assembly-plugin
-
-
- package
-
- single
-
-
- rest-api-${project.version}
- false
-
- src/main/assembly/assembly.xml
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/abstracto-application/rest-api/src/main/assembly/assembly.xml b/abstracto-application/rest-api/src/main/assembly/assembly.xml
deleted file mode 100644
index 75cb4f21d..000000000
--- a/abstracto-application/rest-api/src/main/assembly/assembly.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
- zip
- false
-
- zip
-
-
-
- resources
- ${project.basedir}/src/main/resources
-
-
- .
- ${project.basedir}/src/main/python
-
-
-
\ No newline at end of file
diff --git a/deployment/installer/docker-compose.yaml b/deployment/installer/docker-compose.yaml
deleted file mode 100644
index f104c025c..000000000
--- a/deployment/installer/docker-compose.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-version: "3.7"
-
-services:
- config_deployment:
- build: config-deployment
- image: ${REGISTRY_PREFIX}abstracto-db-deployment:${VERSION:-latest}
- template_deployment:
- build: template-deployment
- image: ${REGISTRY_PREFIX}abstracto-template-deployment:${VERSION:-latest}
\ No newline at end of file
diff --git a/docker-compose.yaml b/docker-compose.yaml
new file mode 100644
index 000000000..0b0414956
--- /dev/null
+++ b/docker-compose.yaml
@@ -0,0 +1,14 @@
+version: "3.7"
+
+services:
+ config_deployment:
+ build: python/deployment/installer/config-deployment
+ image: ${REGISTRY_PREFIX}abstracto-db-deployment:${VERSION:-latest}
+ template_deployment:
+ build: python/deployment/installer/template-deployment
+ image: ${REGISTRY_PREFIX}abstracto-template-deployment:${VERSION:-latest}
+ rest_api:
+ build:
+ context: python/components/rest-api
+ dockerfile: docker/Dockerfile
+ image: ${REGISTRY_PREFIX}abstracto-rest-api:${VERSION:-latest}
diff --git a/python/components/rest-api/docker/Dockerfile b/python/components/rest-api/docker/Dockerfile
new file mode 100644
index 000000000..3fad9eee2
--- /dev/null
+++ b/python/components/rest-api/docker/Dockerfile
@@ -0,0 +1,10 @@
+FROM python:3.10.13-alpine3.18
+RUN apk --no-cache add msttcorefonts-installer fontconfig && \
+ update-ms-fonts && \
+ fc-cache -f
+ADD wrapper /
+ADD python/requirements.txt requirements.txt
+RUN pip install -r requirements.txt
+ADD resources /python/resources
+ADD python /python
+CMD ["/run.sh"]
\ No newline at end of file
diff --git a/abstracto-application/rest-api/src/main/python/__init__.py b/python/components/rest-api/python/__init__.py
similarity index 100%
rename from abstracto-application/rest-api/src/main/python/__init__.py
rename to python/components/rest-api/python/__init__.py
diff --git a/abstracto-application/rest-api/src/main/python/base/__init__.py b/python/components/rest-api/python/base/__init__.py
similarity index 100%
rename from abstracto-application/rest-api/src/main/python/base/__init__.py
rename to python/components/rest-api/python/base/__init__.py
diff --git a/abstracto-application/rest-api/src/main/python/base/image_gen.py b/python/components/rest-api/python/base/image_gen.py
similarity index 100%
rename from abstracto-application/rest-api/src/main/python/base/image_gen.py
rename to python/components/rest-api/python/base/image_gen.py
diff --git a/abstracto-application/rest-api/src/main/python/custom/__init__.py b/python/components/rest-api/python/custom/__init__.py
similarity index 100%
rename from abstracto-application/rest-api/src/main/python/custom/__init__.py
rename to python/components/rest-api/python/custom/__init__.py
diff --git a/abstracto-application/rest-api/src/main/python/main.py b/python/components/rest-api/python/main.py
similarity index 100%
rename from abstracto-application/rest-api/src/main/python/main.py
rename to python/components/rest-api/python/main.py
diff --git a/python/components/rest-api/python/requirements.txt b/python/components/rest-api/python/requirements.txt
new file mode 100644
index 000000000..3d3e1406a
--- /dev/null
+++ b/python/components/rest-api/python/requirements.txt
@@ -0,0 +1,17 @@
+blinker==1.7.0
+certifi==2023.7.22
+charset-normalizer==3.3.2
+click==8.1.7
+Flask==3.0.0
+idna==3.4
+importlib-metadata==6.8.0
+itsdangerous==2.1.2
+Jinja2==3.1.2
+MarkupSafe==2.1.3
+Pillow==10.1.0
+requests==2.31.0
+urllib3==2.0.7
+waitress==2.1.2
+Werkzeug==3.0.1
+zipp==3.17.0
+pytz==2023.3.post1
\ No newline at end of file
diff --git a/abstracto-application/rest-api/src/main/python/utils/__init__.py b/python/components/rest-api/python/utils/__init__.py
similarity index 100%
rename from abstracto-application/rest-api/src/main/python/utils/__init__.py
rename to python/components/rest-api/python/utils/__init__.py
diff --git a/abstracto-application/rest-api/src/main/python/utils/flask_utils.py b/python/components/rest-api/python/utils/flask_utils.py
similarity index 100%
rename from abstracto-application/rest-api/src/main/python/utils/flask_utils.py
rename to python/components/rest-api/python/utils/flask_utils.py
diff --git a/abstracto-application/rest-api/src/main/resources/img/semf_template.jpg b/python/components/rest-api/resources/img/semf_template.jpg
similarity index 100%
rename from abstracto-application/rest-api/src/main/resources/img/semf_template.jpg
rename to python/components/rest-api/resources/img/semf_template.jpg
diff --git a/python/components/rest-api/wrapper/run.sh b/python/components/rest-api/wrapper/run.sh
new file mode 100755
index 000000000..95dc52d51
--- /dev/null
+++ b/python/components/rest-api/wrapper/run.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+echo "Starting python server..."
+cd python
+python3 -u main.py
\ No newline at end of file
diff --git a/deployment/installer/config-deployment/Dockerfile b/python/deployment/installer/config-deployment/Dockerfile
similarity index 100%
rename from deployment/installer/config-deployment/Dockerfile
rename to python/deployment/installer/config-deployment/Dockerfile
diff --git a/deployment/installer/config-deployment/__init__.py b/python/deployment/installer/config-deployment/__init__.py
similarity index 100%
rename from deployment/installer/config-deployment/__init__.py
rename to python/deployment/installer/config-deployment/__init__.py
diff --git a/deployment/installer/config-deployment/python/__init__.py b/python/deployment/installer/config-deployment/python/__init__.py
similarity index 100%
rename from deployment/installer/config-deployment/python/__init__.py
rename to python/deployment/installer/config-deployment/python/__init__.py
diff --git a/deployment/installer/config-deployment/python/liquibase_deploy.py b/python/deployment/installer/config-deployment/python/liquibase_deploy.py
similarity index 100%
rename from deployment/installer/config-deployment/python/liquibase_deploy.py
rename to python/deployment/installer/config-deployment/python/liquibase_deploy.py
diff --git a/deployment/installer/config-deployment/python/main.py b/python/deployment/installer/config-deployment/python/main.py
similarity index 100%
rename from deployment/installer/config-deployment/python/main.py
rename to python/deployment/installer/config-deployment/python/main.py
diff --git a/deployment/installer/config-deployment/python/templates/liquibase.properties.j2 b/python/deployment/installer/config-deployment/python/templates/liquibase.properties.j2
similarity index 100%
rename from deployment/installer/config-deployment/python/templates/liquibase.properties.j2
rename to python/deployment/installer/config-deployment/python/templates/liquibase.properties.j2
diff --git a/deployment/installer/config-deployment/wrapper/deploy.sh b/python/deployment/installer/config-deployment/wrapper/deploy.sh
similarity index 100%
rename from deployment/installer/config-deployment/wrapper/deploy.sh
rename to python/deployment/installer/config-deployment/wrapper/deploy.sh
diff --git a/deployment/installer/template-deployment/Dockerfile b/python/deployment/installer/template-deployment/Dockerfile
similarity index 100%
rename from deployment/installer/template-deployment/Dockerfile
rename to python/deployment/installer/template-deployment/Dockerfile
diff --git a/deployment/installer/template-deployment/__init__.py b/python/deployment/installer/template-deployment/__init__.py
similarity index 100%
rename from deployment/installer/template-deployment/__init__.py
rename to python/deployment/installer/template-deployment/__init__.py
diff --git a/deployment/installer/template-deployment/python/__init__.py b/python/deployment/installer/template-deployment/python/__init__.py
similarity index 100%
rename from deployment/installer/template-deployment/python/__init__.py
rename to python/deployment/installer/template-deployment/python/__init__.py
diff --git a/deployment/installer/template-deployment/python/main.py b/python/deployment/installer/template-deployment/python/main.py
similarity index 100%
rename from deployment/installer/template-deployment/python/main.py
rename to python/deployment/installer/template-deployment/python/main.py
diff --git a/deployment/installer/template-deployment/python/templates_deploy.py b/python/deployment/installer/template-deployment/python/templates_deploy.py
similarity index 100%
rename from deployment/installer/template-deployment/python/templates_deploy.py
rename to python/deployment/installer/template-deployment/python/templates_deploy.py
diff --git a/deployment/installer/template-deployment/wrapper/deploy.sh b/python/deployment/installer/template-deployment/wrapper/deploy.sh
similarity index 100%
rename from deployment/installer/template-deployment/wrapper/deploy.sh
rename to python/deployment/installer/template-deployment/wrapper/deploy.sh