cilki / gameframe.online

GameFrame is a gaming analytics website created for CS373
http://gameframe.online
Apache License 2.0
5 stars 1 forks source link

Decouple frontend and backend #25

Closed cilki closed 6 years ago

cilki commented 6 years ago

Currently the frontend is served through Flask which is not optimal. We need to separate the two components so they work independently.

  1. Use npm server or npm http-server or something else to host the frontend
  2. Update git hooks so build is automatic
  3. Remove Flask route in main.py
therealsamf commented 6 years ago

So are we going to move the static files to S3 and hook it all up with Route53 for production? Or will we be using flask and npm server on the EC2 instance at the same time?

Not that it matters too much, just curious

cilki commented 6 years ago

What does npm server actually do? If it just serves up the bundled js file, then I guess it's equivalent to hosting the bundle on S3 with the appropriate DNS configuration.

therealsamf commented 6 years ago

it doesn't do anything right now. It’s pretty easy to get it to start a static file server serving the html/js/etc files though. I will set it up tomorrow

cilki commented 6 years ago

This is halfway complete. All that's left is to setup the node server. Here's what I tried:

FROM node:latest

WORKDIR /app

RUN npm install http-server -g

EXPOSE 80
CMD npm install && npm run build && http-server /app -p 80

But the server just lists directory contents. How do we get it to actually load the JS?

therealsamf commented 6 years ago

Did you put index.html in the /app folder? You have to run http-server in the same folder as the index.html file is

And then make sure the path in index.html to bundle.js is relative to that location

cilki commented 6 years ago

Got it working. Also you won't need to run the backend anymore because it will be stable at api.gameframe.online pretty soon. I'll make an entry npm start in package.json to run the frontend.