From 2adf28d5ac630521655b57327dddad58c9386f85 Mon Sep 17 00:00:00 2001 From: Jay Bhavsar Date: Thu, 25 Jan 2024 12:14:54 +0530 Subject: [PATCH 1/4] created docker compose file --- docker-compose.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..161a861 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,45 @@ +version: '3' +services: + datastore: + image: google/cloud-sdk + command: gcloud beta emulators datastore start --project=xposedornot --host-port datastore:8000 --no-store-on-disk + ports: + - 8000:8000 + healthcheck: + test: ["CMD", "curl", "-f", "http://datastore:8000"] + interval: 10s + timeout: 5s + retries: 5 + app: + build: . + volumes: + - .:/app + depends_on: + datastore: + condition: service_healthy + links: + - datastore + ports: + - "8080:8080" + environment: + - PORT=8080 + # environment variables for datastore emulator, not needed for production + - DATASTORE_DATASET=xposedornot + - DATASTORE_EMULATOR_HOST=datastore:8000 + - DATASTORE_EMULATOR_HOST_PATH=datastore:8000/datastore + - DATASTORE_HOST=http://datastore:8000 + - DATASTORE_PROJECT_ID=xposedornot + # environment variables for security, can be left unmodified for local developments + - SECRET_APIKEY=your_secret_api_key + - SECURITY_SALT=your_security_salt + - WTF_CSRF_SECRET_KEY=your_wtf_csrf_secret_key + - ENCRYPTION_KEY=7ba9LmVLqozrFTey5E1P9cRv4rtOKHu80JxOODXzYME= # generated in python with print(__import__('cryptography.fernet', fromlist=['Fernet']).Fernet.generate_key().decode('utf-8')) + # environment variables for cloudflare setup, can be left unmodified for local development + - AUTH_EMAIL=your_auth_email + - AUTHKEY=your_auth_key + - CF_MAGIC=your_cf_magic + - CF_UNBLOCK_MAGIC=your_cf_ublock_magic + # environment variables for external services + - XMLAPI_KEY=your_xmlapi_key # can be aquired from https://www.whoisxmlapi.com/ + - MJ_API_KEY=your_mailjet_api_key # can be aquired from https://app.mailjet.com/ + - MJ_API_SECRET=your_mailjet_api_secret From 3a0149808cb09c279f48184f81cba46a1fa70d91 Mon Sep 17 00:00:00 2001 From: Jay Bhavsar Date: Thu, 25 Jan 2024 12:15:26 +0530 Subject: [PATCH 2/4] upgraded python version to 12 --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4ce95c1..3a29a9d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,7 @@ # Use the official lightweight Python image. # https://hub.docker.com/_/python -#FROM python:3.10-slim -FROM python:3.8-slim +FROM python:3.12 # Allow statements and log messages to immediately appear in the Knative logs ENV PYTHONUNBUFFERED True From 85e1b528ab73feb343d71b5125e2f6963ceefe10 Mon Sep 17 00:00:00 2001 From: Jay Bhavsar Date: Thu, 25 Jan 2024 12:36:45 +0530 Subject: [PATCH 3/4] updated readme --- README.md | 61 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index bdba54e..2e06004 100644 --- a/README.md +++ b/README.md @@ -76,36 +76,65 @@ If you spot any problems or have suggestions for improvements, please raise an i And if you want to contribute, we welcome your pull requests. We'll gladly consider any changes or fixes you suggest. -## Installation & pre-requisities +## Quick Start for Local Development -A quick introduction of the minimal setup you need to get this API working. +### Using Docker-Compose -```shell -sudo apt-get install -y google-cloud-sdk google-cloud-sdk-app-engine-python python3-pip google-cloud-sdk-app-engine-python build-essential libffi-dev python-dev -``` +1. **Clone the Repository:** -The requirements.txt file should list all Python libraries XposedOrNot depend on, and they will be installed using: + ```shell + git clone https://github.com/XposedOrNot/XposedOrNot-API + ``` +2. **Update the necessary environment variables in the docker-compose.yml file if needed, then run:** -```shell -pip3 install -r requirements.txt -``` -This installs all the needed requirements and libraries using pip3. + ```shell + docker-compose up + ``` -Before running XposedOrNot-API, you need to, either: + This command will build API and Datastore Docker images. Note that the project source directory is mapped in the Docker container, so any changes in the source code won't require rebuilding the Docker image. + +### Local Installation + +1. **Clone the Repository:** + + ```shell + git clone https://github.com/XposedOrNot/XposedOrNot-API + ``` + +2. **Install Required Packages** + + ```shell + sudo apt-get install -y google-cloud-sdk google-cloud-sdk-app-engine-python python3-pip google-cloud-sdk-app-engine-python build-essential libffi-dev python-dev + ``` + +3. **Install Python Libraries** + + + ```shell + pip3 install -r requirements.txt + ``` + +4. **Setup Google Cloud Datastore** + + Before running XposedOrNot-API, choose one of the following options: - [Run local Google DataStore emulator](https://cloud.google.com/datastore/docs/tools/datastore-emulator) and debug using the local emulator rather than directly connect to Google DataStore. - -```shell -# For posix platforms, e.g. linux, mac: -gcloud beta emulators datastore start -``` + ```shell + # For posix platforms, e.g. linux, mac: + gcloud beta emulators datastore start + ``` - [Authenticate to Google DataStore](https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default) and directly debug using Google DataStore. +5. **Run the applicaiont** + + ```shell + python main.py + ``` ## Contributing From 75963dbb79794f9dd1b7ef64595c8a105a102fcb Mon Sep 17 00:00:00 2001 From: Jay Bhavsar Date: Thu, 25 Jan 2024 16:55:30 +0530 Subject: [PATCH 4/4] fixed typos, spcified python version --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2e06004..c1eac89 100644 --- a/README.md +++ b/README.md @@ -130,10 +130,10 @@ And if you want to contribute, we welcome your pull requests. We'll gladly consi - [Authenticate to Google DataStore](https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default) and directly debug using Google DataStore. -5. **Run the applicaiont** +5. **Run the application** ```shell - python main.py + python3 main.py ``` ## Contributing