diff --git a/register-api/README.md b/register-api/README.md index 6fb10ea..85fb784 100644 --- a/register-api/README.md +++ b/register-api/README.md @@ -1,6 +1,8 @@ -## Quick Start (local everything via docker compose) +## Quick Start + +These commands bring up everything via Docker compose. It does not allow for local development. ``` source env.sample.noauth @@ -8,10 +10,6 @@ docker-compose build docker-compose up ``` -# Docker -Pre-built docker containers are available. - - ## Configuration Most configuration for the service is setup through environment variables. @@ -75,23 +73,72 @@ token = s._session.get_auth().get_token() ## Development Setup -### Create a virtual env and install python +### Create a Python Enviroment + +If using Conda create a new Conda environment: + +``` +conda create -f environment.yml +conda activate register-api +``` + +Otherwise create a Python virtual environment. Your system will need to already have rust installed: ```python -m venv .venv source .venv/bin/activate pip install --upgrade pip +``` + +Install the package requirements and the register-api software into the Python environment: + +``` pip install -r requirements.txt +pip install -e . ``` -### start up a postgres server -### update inis, env files +### Start up the Postgres Server + +The docker compose file can be used to load a local development Postgres server without running the register-api application: -### Run the server -.venv/bin/uvicorn main:app --reload +``` +docker compose up db -d +``` + +The database is stored persistently in a named Docker volume. + +### Initialize the database + +The following script will initialize the Postgres database. You will need to have installed the register-api package into the Python environment for this command to work. + +``` +python ap/db/init_db.py +``` + +### Environment Variables + +The `env.local_dev` file contains the environment variables necessary for directing the locally running instance of register-api to the Docker launched postgres database as well to a locally running Invenio RDM instance. + +Source this file into the shell environment before running the server: + +``` +source env.local_dev +``` + +### Run the Server + +With dependencies configured and the database running and initialized you can launch the local development version of the register-api server. The `--reload` causes the server to restart when changes to the software are made. + +``` +uvicorn main:app --reload +``` ## Docker Setup -`docker-compose up` +Run Docker compuse without specifying a target: + +``` +docker-compose up +``` ## Database Cleanup @@ -104,4 +151,4 @@ docker-compose down -v # Start fresh docker-compose up --build -``` +``` \ No newline at end of file diff --git a/register-api/env.local_dev b/register-api/env.local_dev new file mode 100644 index 0000000..536adbc --- /dev/null +++ b/register-api/env.local_dev @@ -0,0 +1,21 @@ +# API Configuration +export API_V1_STR=/api/v1 +export PROJECT_NAME="MDPS Artifact Catalog" + +# Database Configuration +# Must be updated fro non-local usage +export DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:5433/mdps_catalog + +# Storage Configuration +export STORAGE_PATH=./storage + +export DESTINATION_REGISTRY=123.dkr.ecr.us-west-2.amazonaws.com + +export JWT_AUTH_TYPE=RDM +export JWT_VALIDATION_URL= +export JWT_ISSUER_URL= +export JWT_CLIENT_ID= +export JWT_GROUPS_KEY= + +#RDM Config +export RDM_URL=https://127.0.0.1:5000 diff --git a/register-api/environment.yml b/register-api/environment.yml index 38df6d6..e4d24ba 100644 --- a/register-api/environment.yml +++ b/register-api/environment.yml @@ -3,4 +3,5 @@ channels: - conda-forge dependencies: - python<=3.12 -- rust \ No newline at end of file +- rust +- psycopg2-binary==2.9.9 # Install here or else get segfaults in psycopg2 module when installed through pip \ No newline at end of file