On Sun, 24 Nov 2019 at 01:31, Sam Ruby <ru...@intertwingly.net> wrote:
> On Sat, Nov 23, 2019 at 7:15 PM sebb <seb...@gmail.com> wrote: > > > > The Puppet init.pp script [1] sets up several directories which are not > yet > > reflected in the Docker build, e.g. /srv/cache > > > > Where is the best place to set these up? > > Short answer: in the Dockerfile. > > /srv is dynamically mapped, so if Dockerfile creates /srv/cache won't it be overridden? > Longer answer: > > 1) Anything that is static and idempotent can and should be build in > the Dockerfile. The theory is that you should be able to destroy a > container and rebuild it from the Dockerfile and end up with exactly > the same image. In practice this isn't exactly true (apt-get update > may get newer versions of packages, for example), but is close enough > to be true in practice. One thing that a Dockerfile can NOT depend on > is mounted file systems or environment variables. docker-compose.yaml > can make use of environment variables. > 2) Anything that is in the container (e.g.. changes made by commands > invoked via RUN or EXEC) should be ephemeral. If a container is > pruned, there should not be anything lost of significance. > > 3) Everything else should go into a volume as volumes have lives > outside of images and containers. Host volumes are mounted, and on > macOS and Windows have performance characteristics of a remote file > system (e.g. nfs) whereas on Linux they have native mounted > performace. Anonymous and named volumes have native performance on > all operating systems, but can't be directly accessed by the host > machine. > > Notes: > > 1) During development, the contents of the local clone of whimsy and > even the gems installed are generally not considered static, and hence > belong on a volume. > > 2) The current docker:entrypoint rake task contains only commands that > can be run fast and depend on things like contents of volume mounts > (e.g. the whimsy source code) or environment variables (the name of > the user's home directory). > > So would that be the place to set up /srv/cache ? > - Sam Ruby > > > [1] > > > https://github.com/apache/infrastructure-puppet/blob/deployment/modules/whimsy_server/manifests/init.pp#L178 >