README.md

plumber API for the polished R package

Lifecycle:
maturing Travis-CI Build Status

CAUTION: do not try to install the polishedapi right now. It is not ready for general usage.

Installation Requirements

Installation

  1. Set up PostgreSQL "polished" schema. This schema stores your users, apps, and information about which users are authorized to access which apps. It also keeps track of user sessions. To create this schema you must have a PostgreSQL database.
# R
# read in your database credentials
db_config <- config::get(file = "inst/plumber/api/config.yml")$db

# connect to your PostgreSQL database
db_conn <- polishedapi::db_connect(db_config)

# create the "polished" schema.
# Warning: if you already have a polished schema this function will overwrite 
# your existing schema with empty tables.
polishedapi::create_schema(db_conn)

# create your account. e.g. my account can be created like so:
account <- polishedapi::add_account(
  db_conn,
  email = "andy.merlino@tychobra.com",
  host_secret = "my_super_secret"
)

# replace my email ("andy.merlino@tychobra.com") above with your email, and 
# replace the "host_secret" with the host secret that you deploy with your polishedapi.
  1. Add your database credentials to "inst/plumber/api/config.yml". This is where your "host_secret" needs to be stored as your "polished_hosted_secret"."

  2. Build the polished API Docker image.

# terminal

# build the docker image
docker build -t polished_api ./inst/plumber

# run the docker container.  This is useful for local testing.
docker run --rm -p 8080:8080 polished_api

Note: Open bash shell inside running docker container. This is useful for debugging.

# terminal

docker exec -it $(docker ps -q) /bin/bash

Note: if you run several docker containers on your local computer, you may end up leaving some of them running by accident. You can clean up all running Docker container with the collowing command:

# terminal

# cleanup running containers
docker stop $(docker ps -q)
  1. Deploy the polished API Docker image to a server that can run a Docker container. Popular solutions are Google Cloud Run and AWS Fargate.
# tag image for deployment to GCR (Google Container Registry)
docker tag polished_api gcr.io/postgres-db-189513/polished_api

# push tagged image to GCR
docker push gcr.io/postgres-db-189513/polished_api
  1. Follow the docs at polished.tech to configure your Shiny apps to use polished.


Tychobra/polishedapi documentation built on July 19, 2020, 11:41 p.m.