pachadotdev / tradestatistics-plumber-api

tradestatistics.io API, reads from PostgreSQL and provides tidy CSV and Apache Arrow data
https://api.tradestatistics.io/
Apache License 2.0
2 stars 1 forks source link

running plumber with... docker? #2

Closed pachadotdev closed 5 years ago

pachadotdev commented 5 years ago

Hi!

I have pushed a decent API draft. I saw here and docker seems to be a suitable method to run the API in the server and then go data.local/api/yr?y=2010&r=chl or whatever from firefox

What do you think about docker and/or other methods?

pachadotdev commented 5 years ago

Update: Docker works now

I created an image with RPostgreSQL named tradestatistics/plumber-api. There are two main problems I can detect:

  1. I have to type

    cd /the_directory/something/
    docker run --rm -p 8000:8000 -vpwd`/queries_with_db_credentials.R:/plumber.R tradestatistics/plumber-api /plumber.R

    to make it run, and then with ctrl+c I stop the api, but the cool working would be after I reboot the server and it runs in automatic mode

  2. When I read from R I have to type fromJSON twice to get the tibble, that's probably bc the code in this repo is not cool.

Plz see the screenshots where I show that it works :)

image10 image11

pachadotdev commented 5 years ago

Update 2: I was able to make this simpler

If I go to ~/github/ts-plumber-api and then I run docker run -p 8080:8000 tradestatistics/plumber-api then it runs ok as shown in the screenshots

I still cannot make it work automatically after restarting the server

in any case, you can go to http://trade.stats:8080/yr?y=2010&r=chl or similar and dig a bit to explore this API (trade.stats is a redirect that points to the IP that I don't wanna reveal yet, this is WIP)

screenshot from 2018-12-17 01-25-58 screenshot from 2018-12-17 01-26-20

pachadotdev commented 5 years ago

there was something not ok on plumber docs, this command enables run after boot

docker run -p 8080:8080 -dit --restart unless-stopped tradestatistics/plumber-api
aedobbyn commented 5 years ago

Not super familiar with docker so this might be something simple -- running the command you have above from the repo directory I get

Unable to find image 'tradestatistics/plumber-api:latest' locally
docker: Error response from daemon: pull access denied for tradestatistics/plumber-api, repository does not exist or may require 'docker login'.
See 'docker run --help'.
pachadotdev commented 5 years ago

Strange... It was working

What do you see if you open a browser tab and go to "the.site:8080/status"?

On Mon, Dec 17, 2018, 9:25 PM Amanda Dobbyn <notifications@github.com wrote:

Not super familiar with docker so this might be something simple -- running the command you have above from the repo directory I get

Unable to find image 'tradestatistics/plumber-api:latest' locally docker: Error response from daemon: pull access denied for tradestatistics/plumber-api, repository does not exist or may require 'docker login'. See 'docker run --help'.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/tradestatistics/ts-plumber-api/issues/2#issuecomment-448050220, or mute the thread https://github.com/notifications/unsubscribe-auth/AJn6Ob1kbBlLMipJlO20JengWqY_ucuaks5u6DYCgaJpZM4ZTpxG .

pachadotdev commented 5 years ago

@aedobbyn it's probably something related to /home permissions what I did to make it work was (from home)

cd github
git clone git@github.com:tradestatistics/ts-plumber-api.git
docker build -t tradestatistics/plumber-api .
docker run -p 8080:8080 -dit --restart unless-stopped tradestatistics/plumber-api
pachadotdev commented 5 years ago

to avoid potential permissions problems I created /api with permissions for all users, there I moved what I had on my home dir