Skip to content

Commit

Permalink
Update installation requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Mar 6, 2024
1 parent fe21cbc commit 0011b55
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ RUN apt-get update \

COPY --from=builder /root/.local /home/appuser/.local
COPY README.md .
COPY config.txt.sample ./config.txt

# Enable this if you are using config.txt
# COPY config.txt ./config.txt

COPY setup.py .
COPY API/ ./API/
COPY src/ ./src/
Expand Down
4 changes: 4 additions & 0 deletions docs/src/installation/configurations.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

# Configuring the API service

Raw Data API can be setup using two configuration options. You can choose based on your convienience
- *config.txt* : You can follow `config.txt.sample` in dir and documentation below to set your configurations
- *.env* : Another option is from OS Environment variable , You can export all your env variables ( They are same as you put in config without blocks ) and pass it to API , API will pick it up automatically.

## What you need to start?

- A working [Postgres](https://www.postgresql.org/) instance with [Postgis](https://postgis.net/) module enabled.
Expand Down
46 changes: 42 additions & 4 deletions docs/src/installation/docker.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
## Initial Setup

- Clone the repository, and change directory to _export-tool-api_ folder on your computer.
### Clone

- Clone the repository, and change directory to _raw-data-api_ folder on your computer.

```
git clone https://github.com/hotosm/export-tool-api.git
cd export-tool-api
git clone https://github.com/hotosm/raw-data-api.git
cd raw-data-api
```

## Configurations

### config.txt approach
- Create `config.txt` inside / folder. You can use any of the appropriate commands below or you use your familiar methods in your code editor/file explorer.

```
touch config.txt #Linux
wsl touch config.txt #Windows with WSL
echo >> config.txt #Windows without WSL
```
#### .env approach

if you prefer configurations as env variables you can put them in `.env` and pass it to dockerfile or export them

- Database configuration:
- To use the default database(with sample data) shipped with the `Dockerfile`, you can update the `config.txt` with the configurations below. [**Recommended**]

- Make sure you uncomment ```COPY config.txt ./config.txt``` line in Dockerfile while using `config.txt`

- To use a local postgres (with postgis enabled) database, you can follow the instruction on how to set it up with raw data [here](./configurations.md). or export them as system env variables

```
Expand All @@ -42,12 +51,41 @@ CELERY_RESULT_BACKEND=redis://redis:6379/0
- Follow this step to setup OSM OAuth: [Setup Oauth Block](./configurations.md#Setup-Oauth-for-Authentication).
- Update your `config.txt` with the `[OAUTH]` block from the step above.

## Create the Docker images and spin up the containers

## Run Docker

You can either use full composed docker-compose directly or you can build docker containers manually .

### Spin up the containers using docker compose

```
docker-compose up -d --build
```

OR

### Run Docker without docker compose

- Build your image
```
docker build -t rawdataapi:latest .
```
- Run API
```
docker run -d -p 8000:8000 --name rawdatapi rawdataapi:latest
```
Run container with `.env` file

```
docker run --env-file ./.env -d -p 8000:8000 --name rawdatapi rawdataapi:latest
```

- Run Workers
```
docker run -it rawdataapi:latest celery --app API.api_worker worker --loglevel=INFO --queues="raw_ondemand" -n 'default_worker'
```
Followi similar for flower

## Check the servers

By default, Uvicorn would be running on port [8000](http://127.0.0.1:8000/v1/docs), Redis on default port(i.e 6379), Celery with a worker and Flower on port [5000](http://127.0.0.1:5000/).
Expand Down
9 changes: 4 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,17 @@ geomet==1.1.0
# flower
flower==2.0.1

##sozipfile
sozipfile==0.3.2

##duckdb
duckdb==0.9.2

##hdx
hdx-python-api==6.2.0

## only needed if used postgres as celery backend
## only needed if postgres is used as celery backend
SQLAlchemy==2.0.25


##sozipfile
sozipfile==0.3.2
## zip memory optimization
zipfly==6.0.5
psutil==5.9.8

0 comments on commit 0011b55

Please sign in to comment.