Merge in current hosting branch, which is our active server#147
Merge in current hosting branch, which is our active server#147davemfish merged 54 commits intonatcap:developfrom
Conversation
… CORS origin list
…-online-workflow into feature/vm-hosting
…-online-workflow into feature/vm-hosting
…non 443 ports. The endpoint 9000 is handled with a proxy pass to fileserver:9000
…ons endpoint, see comment note
…play with certbot on the image itself.
… caussing https ssl issues, so now 443 just does a proxy pass to localhost:8000
…hey were useful or not. Moving port 8000 and 9000 calls to 443 location proxy_pass redirects. Lots of SSL configuration and setup. Lots of things added to try and work and MixedContent errors and SSL erros.
…nginx. nginx when handling the request drops the trailing slash, which was causing a http redirect, which caused a https / http conflict
… cert issues. Commenting out return calls from GET / POST that were interfering with FastAPI returns, which caused a json error on the frontend.
…en renewing certs, since all traffic is being redirected to 443.
…seeing an error when trying to dump to a json file. It was related to trying to serialize a float, so I casted to a string.
…because I was seeing a malformed URL request in dev mode. 'localhost/9000scenarios/...'. I'm not sure why this is showing up with localhost and not in production.
davemfish
left a comment
There was a problem hiding this comment.
Just a few misc things that caught my eye.
backend-worker/invest_results.py
Outdated
| for output, output_path in carbon_outputs.items(): | ||
| carbon_results[output] = pygeoprocessing.raster_reduce( | ||
| lambda total, block: total + numpy.sum(block), (output_path, 1), 0) | ||
| carbon_results[output] = f"{carbon_results[output]}" |
There was a problem hiding this comment.
Hmm, did something just break that required this? There's a json.dump(carbon_results) below. If there was something un-serializable in that data I wonder if it's a sign of a larger problem?
There was a problem hiding this comment.
Yes, I was seeing some breaking behavior in the logs of invest_results.py I hadn't before (that I can remember). It was reporting that 'float32' was not serializable. It looks like numpy.float32 is NOT serializable, but numpy.float64 is. It looks like, np.float64 is a subclass of float which is why it's serializable but np.float32 is not. We could also cast to float here, which is maybe what I'll do instead.
| WORKDIR /opt/frontend | ||
|
|
||
| ADD ./package.json /opt/frontend/ | ||
| RUN yarn add puppeteer --ignore-scripts |
There was a problem hiding this comment.
puppeteer is already listed in the package.json, so I wouldn't expect to need to add it here everytime.
There was a problem hiding this comment.
When running docker compose up –build the frontend container would hang indefinitely trying to build packages as part of yarn install.
It appears this was an issue with puppeteer, perhaps downloading Chromium
forever building fresh packages :( · Issue #5268 · yarnpkg/yarn · GitHub
Following the link above, a user suggested this, which worked right away for me.
There was a problem hiding this comment.
Let me know your thoughts on this and including yarn.lock. That puppeteer Chromium thing was a real blocker for me in a docker set up unfortunately.
frontend/package.json
Outdated
| "start": "vite", | ||
| "start-docker": "cross-env MODE=docker vite --host 0.0.0.0 --port 3000", | ||
| "start-docker-prod": "cross-env MODE=docker VITE_DEVMODE=false vite --host 0.0.0.0 --port 3000", | ||
| "start-docker-dev": "cross-env MODE=docker VITE_DEVMODE=true vite --host 0.0.0.0 --port 3000", |
There was a problem hiding this comment.
technically I think we're always using the vite dev server, even in production. So VITE_DEVMODE might be a bit misleading. Is it better as APP_DEV_MODE, or just DEVMODE?
There was a problem hiding this comment.
It is confusing, but I found I had to use VITE_ in conjunction with import_meta.env, otherwise the environment variable was not known.
To prevent accidentally leaking env variables to the client, only variables prefixed with VITE_ are exposed to your Vite-processed code.
So, we could rename it: VITE_UO_DEV_MODE or VITE_URBANONLINE_DEVMODE...
There was a problem hiding this comment.
Updated to VITE_URBANONLINE_DEVMODE here: dca5e9e
Happy to change this to something else.
| @@ -5,7 +5,9 @@ RUN mkdir /opt/frontend | |||
| WORKDIR /opt/frontend | |||
|
|
|||
| ADD ./package.json /opt/frontend/ | |||
There was a problem hiding this comment.
I wonder if we should also be adding the yarn.lock file, to speedup the yarn install.
There was a problem hiding this comment.
That could definitely be handy. See my note below on Chromium really slowing down / stopping the yarn install step when getting puppeteer.
| #RUN yarn cache clean && yarn install --production=false | ||
|
|
||
| EXPOSE 3000 | ||
|
|
There was a problem hiding this comment.
I guess it's not used during docker compose, but the last (next) line in this Dockerfile could be updated to yarn start-docker-dev
There was a problem hiding this comment.
Right, or we just comment out / remove it all together. I'll update it for now.
Mostly set up of an nginx proxy server.