osoc21 / technical-support

Technical Support
0 stars 1 forks source link

R API on the server #3

Closed AnastasiaDv491 closed 3 years ago

AnastasiaDv491 commented 3 years ago

Is your request related to a problem? Please describe. connecting to a server like Netlify (since our team doesnt have an experience with it)

Describe the solution you'd like Ability to push R based API to the server.

Describe alternatives you've considered Havent considered much becuase we are a bit clueless on what to do for the server

jbelien commented 3 years ago

I don't think it's possible to deploy R code on Netlify.

I would suggest to use Docker (and a Dockerfile). Once your Dockerfile is ready (in your repository), ping me here and I'll setup an automated deployment for it using Digital Ocean App Platform.

AnastasiaDv491 commented 3 years ago

thanks ! will try to figure it out

ErinnVdSande commented 3 years ago

@jbelien I have created a docker-compose and a dockerfile but I have never worked with the technology before so I can only get it running with the compose right now. Is that good enough?

jbelien commented 3 years ago

@jbelien I have created a docker-compose and a dockerfile but I have never worked with the technology before so I can only get it running with the compose right now. Is that good enough?

I won't need the docker-compose.yml file. I just need the Dockerfile. Locally you can use docker compose if you want. You can also use docker build + docker run ; that's what I will use.

Is this already pushed to somewhere I can check ?

ErinnVdSande commented 3 years ago

It's on the https://github.com/osoc21/Future-of-Work on the hackaton branch in the backend folder

jbelien commented 3 years ago

Your dockerfile seems correct (even though I would rename it Dockerfile).

As I said, I don't need your docker-compose.yml file. Could you try the following (I didn't test it, might need some tweaking) ?

docker build ./backend/ --no-cache -t api-service
docker run --publish 7000:8000 --volumes ./backend/api.R:/app/api.R api-service

The first command builds an image called "api-service". The second command runs the image with the parameters you chose.

ErinnVdSande commented 3 years ago

I get an error on the second line

docker run --publish 7000:8000 --volumes ./backend/api.R:/app/api.R api-service

unknown flag: --volumes See 'docker run --help'.

jbelien commented 3 years ago

Indeed, it's --volume instead of --volumes.

docker run --publish 7000:8000 --volume ./backend/api.R:/app/api.R api-service

Please read docker build and docker run documentation.

jbelien commented 3 years ago

Side note, I think that COPY (see documentation) in your Dockerfile is the way to go (instead of --volume).

ErinnVdSande commented 3 years ago

Yeah I changed it to a COPY and pushed it to the branch the commands i use now are: docker build ./backend/ --no-cache -t api-service and docker run --publish 7000:8000 api-service

archived-m commented 3 years ago

@jbelien I think this can be closed given that we moved away from R in its entirety. We'll open a new issue when we're ready to deploy and our Dockerfile is up to snuff :)