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

Decide on filesystem layout #246

Open
nam20485 opened this issue Feb 26, 2024 · 3 comments
Open

Decide on filesystem layout #246

nam20485 opened this issue Feb 26, 2024 · 3 comments

Comments

@nam20485
Copy link
Owner

I am not clear on the idiomatic/conventional way to lay out the directory structure for an app such as this. I suppose putting the executable in /usr/local/bin would be most correct?

However there are two other directories required by the executable at runtime:

  1. templates/ (where mustache templates for templated HTML endpoints created by the user are found, needs read access)
  2. designs/ (where uploaded ODB++ designs are located and then read from, needs r/w access)

Currently the directory structure is thus:

/OdbDesignServer
   /templates
   /designs
   OdbDesignServer (exe)

I suppose the two runtime directories should be placed in /var somewhere?

The path for the two directories can be specificed at launch via CLI args. Try ObdDesignServer --help or see the ENTRYPOINT key in the Dockerfile for more details.

@oliv3r
Copy link

oliv3r commented Feb 28, 2024

'it depends'. How would you run make install normally? It is not uncommon to do a make install (when compiling in the container from scratch) and let it install things into /usr/local/bin (instead of /usr/bin).

In a multi-stage container build, you'd start with doing a make && make DESTDIR=/odbdesign install for example, this would install the app in a strange ___location like /odbdesign/usr/local/bin etc.

Then in the next stage, you'd do COPY --from=builder "/odbdesign" "/"

Obviously, this would require the application to work in such a way, with all expected filepaths.

It's fine to install into opt (with some path changes, though much preferred in that case would be an init script in /usr/local/bin

See here for an example that I did: https://github.com/tvheadend/tvheadend/blob/master/Containerfile.alpine

@nam20485
Copy link
Owner Author

nam20485 commented Feb 28, 2024

@oliv3r That makes sense. The app is configured and built using CMake, so instead of using configure and make install, CMake creates ninja make files during the configure step and another call is made run the build via the 'ninja` make files.

$ cmake configure
$ cmake build

I believe the equivalent to make install for CMake projects would be cmake install. This would require that I implement the CMake configuration for the install target. This approach would probably be the most idiomatic way to install the build output, and would replace the Dockerfile steps that manually install the binaries (which would be a 'good thing').

I already have the multi-stage build in my Dockerfile, so the changes would only be to modify the first "builder" stage to use the cmake install command and then modify my existing COPY --from=builder "/odbdesign" "/" to copy from the new locations.

I will create a PR with these changes. Thank you for the input!

@oliv3r
Copy link

oliv3r commented Mar 2, 2024

Btw, here's an example I did a while ago for cmake. I probably have better ones, but my memory fails me :)

https://github.com/Cisco-Talos/clamav-docker/blob/main/clamav/unstable/alpine/Dockerfile

the example is a bit 'confusing' as it does a few unexpected/non-standard things, but overal, still a good example using cmake.

I think https://github.com/Cisco-Talos/clamav-docker/blob/main/clamav/unstable/alpine/scripts/docker-entrypoint-unprivileged.sh is also useful for a decent, still simple, daemonized entry point for the container (which would have been my next issue report :p)

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

No branches or pull requests

2 participants