Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 chore: Improving Developer Onboarding #XON-Hackathon-2024 #10

Merged
merged 4 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not using slim version, since some of the dependencies need to be compiled with gcc, which is not included in slim.


# Allow statements and log messages to immediately appear in the Knative logs
ENV PYTHONUNBUFFERED True
Expand Down
61 changes: 45 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 application**

```shell
python3 main.py
```

## Contributing

Expand Down
45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Loading