Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Standalone Production config #134

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

buti1021
Copy link

Following the excellent work by Anthony I split the nginx into a proper config production which doesnt use the vite development server.

I still have a few open questions/remarks I want to discuss:

  1. Env File, imo we should put the .env into version control, just an example of it. My prefered solution would be to create a file called .env-example and .gitignore the .env file.
  2. The development version as provided right now is not really working, as the vite can't access the wss for HMR. I would ask the question if we should really use nginx for the dev setup. Happy for your input here.
  3. Healthchecks: @bendhouseart Your changes to the healthchecks in the compose file, didn't work for me. What was the point behind your changes?
  4. Startup scripts (dev.sh and prod.sh) I see the benefit of those files (git submodules & key generation) but also would try to look for a streamlining of the storage of environment variables (script vs. .env) and the duplication of code between the dev and prod file. + I don't completly understand why the npm dependencies are installed in that script and not in the Dockerfiles of the corresponding containers. Option might be to merge dev and prod into a start.sh with more flags.
  5. Nginx config file, I think this a good starting point, not sure tho how far we can go with this as setups are quiet different (e.g. we have dont have our cert key encrypted and as a result don't have a ssl_password_file. Thus the nginx fails. Maybe remove the config from the code repo and put it into the documentation as an example instead?
  6. The api still runs in dev mode more or less. Didn't completly get what the start.sh is used for here (maybe nowhere at all?). Might have time to tackle that in the next few days.

Happy for your input.

Best,

Tim

@bendhouseart
Copy link
Contributor

bendhouseart commented Sep 30, 2024

Env File, imo we should put the .env into version control, just an example of it. My prefered solution would be to create a file called .env-example and .gitignore the .env file.

Yes, that makes sense, but I prefer example.env ;). I think it's worth adding an if [ ! -f .env ]; then cp example.env .env fi somewhere to handle things (adding this to my branch right now).

The development version as provided right now is not really working, as the vite can't access the wss for HMR. I would ask the question if we should really use nginx for the dev setup. Happy for your input here.

I'd like to commit to nginx always being run b/c that makes the development and production environments as similar as possible (barring how brainlife.io deploys things). That is to say I think it's simpler to have 2 nginx configuration files and 1 env file then to have multiple docker compose files, but that solution while being simpler to me may not be the best path forward.

Healthchecks: @bendhouseart Your changes to the healthchecks in the compose file, didn't work for me. What was the point behind your changes?

It was required as the health checks were failing when reaching out to localhost after we got nginx up and behaving. Since we were all in on nginx it seemed like a good idea to just go with it in the compose too.

Startup scripts (dev.sh and prod.sh) I see the benefit of those files (git submodules & key generation) but also would try to look for a streamlining of the storage of environment variables (script vs. .env) and the duplication of code between the dev and prod file. + I don't completly understand why the npm dependencies are installed in that script and not in the Dockerfiles of the corresponding containers. Option might be to merge dev and prod into a start.sh with more flags.

Yeah, I had some similar remarks about the run/build process, but I think it's helpful to keep in mind that this is not how ezbids is deployed on brainlife.io. Technically speaking, everything we've been doing has been "non-production" compared to how this project was originally scoped/intended to work.

I agree and will be working today to streamline the launch/build process to better leverage:

  • environment variables via .env and otherwise
  • making dev.sh a bit more explicit by renaming it launch.sh
  • adding more options to dev.sh/launch.sh for production, rebuilding/installing npm after mounting etc.

Nginx config file, I think this a good starting point, not sure tho how far we can go with this as setups are quiet different (e.g. we have dont have our cert key encrypted and as a result don't have a ssl_password_file. Thus the nginx fails. Maybe remove the config from the code repo and put it into the documentation as an example instead?

When I requested my ssl certs I encrypted the keys, I'm not sure of a clever way around this within the nginx config. Before we think too much on this, could you try running the http version (point to nginx/development_nginx.conf) instead? My thinking is to use the http nginx enabled version for local development and the https nginx version for production going forward.

The api still runs in dev mode more or less. Didn't completly get what the start.sh is used for here (maybe nowhere at all?). Might have time to tackle that in the next few days.

No idea either, but I think consolidation is the word of the week for my branch.


RUN npm install

CMD [ "npm", "run", "build"]
Copy link
Contributor

@bendhouseart bendhouseart Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So when I switch over to using the build option it seems to break my application and make it unusable. Do the options build and dev that get used in this docker file correspond to this ->

"scripts": {
"dev": "vite --host",
"build": "vite build --base=/ezbids/",
"serve": "vite preview"
},

Really not sure what exactly is all going on here, but it feels like we're pretty close...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What further confuses me is what effect this vite config has, see ->

export default defineConfig({
base: '/ezbids/',
plugins: [
vue(),
Components({
resolvers: [ElementPlusResolver()],
}),
ViteYaml(),
],
build: {
sourcemap: true,
},
});

Is this at all related to the page refreshing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants