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

book: Move /opt redirection guidance to building #520

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
book
mermaid*.js
32 changes: 32 additions & 0 deletions docs/src/building/guidance.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,35 @@ for example, although this can run afoul of SELinux labeling.

There is a dedicated document for [secrets](secrets.md),
which is a special case of configuration.

## Handling read-only vs writable locations

The high level pattern for bootc systems is summarized again
this way:

- Put read-only data and executables in `/usr`
- Put configuration files in `/usr` (if they're static), or `/etc` if they need to be machine-local
- Put "data" (log files, databases, etc.) underneath `/var`

However, some software installs to `/opt/examplepkg` or another
location outside of `/usr`, and may include all three types of data
undernath its single toplevel directory. For example, it
may write log files to `/opt/examplepkg/logs`. A simple way to handle
this is to change the directories that need to be writble to symbolic links
to `/var`:

```dockerfile
cgwalters marked this conversation as resolved.
Show resolved Hide resolved
RUN apt|dnf install examplepkg && \
mv /opt/examplepkg/logs && /var/log/examplepkg && \
ln -sr /opt/examplepkg/logs /var/log/examplepkg
```

The [Fedora/CentOS bootc puppet example](https://gitlab.com/fedora/bootc/examples/-/tree/main/opt-puppet)
is one instance of this.

Another option is to configure the systemd unit launching the service to do these mounts
dynamically via e.g.

```
BindPaths=/var/log/exampleapp:/opt/exampleapp/logs
```
17 changes: 5 additions & 12 deletions docs/src/filesystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,11 @@ Besides those, for other toplevel directories such as `/usr` `/opt`, they will b
In the default suggested model of using composefs (per above) the `/opt` directory will be read-only, alongside
other toplevels such as `/usr`.

Some software expects to be able to write to its own directory in `/opt/exampleapp`. A common
pattern is to use a symbolic link to redirect to e.g. `/var` for things like log files:
Some software (especially "3rd party" deb/rpm packages) expect to be able to write to
a subdirectory of `/opt` such as `/opt/examplepkg`.

```
RUN rmdir /opt/exampleapp/logs && ln -sr /var/log/exampleapp /opt/exampleapp/logs
```

Another option is to configure the systemd unit launching the service to do these mounts
dynamically via e.g.
```
BindPaths=/var/log/exampleapp:/opt/exampleapp/logs
```
See [building images](building/guidance.md) for recommendations on how to build
container images and adjust the filesystem for cases like this.

#### Enabling transient root

Expand All @@ -145,4 +138,4 @@ transient = true
```

option in `prepare-root.conf`. In particular this will allow software to write (transiently) to `/opt`,
with symlinks to `/var` for content that should persist.
with symlinks to `/var` for content that should persist.
Loading