diff --git a/Dockerfile b/Dockerfile index a63f41b8..07f6416e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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/ diff --git a/docs/src/installation/configurations.md b/docs/src/installation/configurations.md index b847122c..94c3eed0 100644 --- a/docs/src/installation/configurations.md +++ b/docs/src/installation/configurations.md @@ -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. diff --git a/docs/src/installation/docker.md b/docs/src/installation/docker.md index e5425570..08968496 100644 --- a/docs/src/installation/docker.md +++ b/docs/src/installation/docker.md @@ -1,14 +1,17 @@ ## 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. ``` @@ -16,9 +19,15 @@ 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 ``` @@ -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/). diff --git a/requirements.txt b/requirements.txt index a7a88af4..efa311ed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 \ No newline at end of file