Open corviday opened 1 year ago
That branch does not pre-build the React app. The app is built in entrypoint.sh
, which is executed when the container is spun up, not when the image is built. Unless I missed something here, like a Dockerfile I didn't spot.
The last commit is the one that gets rid of entrypoint.sh
and prebuilds the app.
OK, I did miss a Dockerfile: there's ./Dockerfile
and ./docker/Dockerfile
!
The problem with pre-building the React app in the Docker image is that it binds all enviroment variables at app build time. In that case, their values at container run time have no effect; they are already bound. And that means you can't configure different instances (containers) at run time using env vars. In particular, in this app, you can't specify different app root URLs, nor different URLs for backend services, nor anything else configured via env vars.
That's the reason we build the app at run time, because that way the build does have access to our run-time, per-container settings of env vars.
The rigmarole with the version variable is so that the version info, which the container can't otherwise access, is passed forward to it from image build time. James did make that much simpler, however; not sure why I got caught up in the need to pass it into the image build process from outside, unless there is a gotcha there I've forgotten.
@jameshiebert implemented this functionality in this branch. I was unable to get it to work - there were strange ncWMS errors that did not seem obviously related to the changes, but went away when the changes were removed - but it would be very convenient to have this working someday!
Note that all environment variables have to be specified at build time, so in order to build the image, you need to edit the environment variables into
docker/frontend.env
, then build the image withdocker build -t scip:dockerize -f docker/Dockerfile .