internal/pkg: automatic overlay mount on tmp
All checks were successful
Test / Create distribution (push) Successful in 52s
Test / Sandbox (push) Successful in 2m54s
Test / ShareFS (push) Successful in 4m46s
Test / Sandbox (race detector) (push) Successful in 5m20s
Test / Hakurei (push) Successful in 5m35s
Test / Hpkg (push) Successful in 5m34s
Test / Hakurei (race detector) (push) Successful in 7m37s
Test / Flake checks (push) Successful in 1m48s
All checks were successful
Test / Create distribution (push) Successful in 52s
Test / Sandbox (push) Successful in 2m54s
Test / ShareFS (push) Successful in 4m46s
Test / Sandbox (race detector) (push) Successful in 5m20s
Test / Hakurei (push) Successful in 5m35s
Test / Hpkg (push) Successful in 5m34s
Test / Hakurei (race detector) (push) Successful in 7m37s
Test / Flake checks (push) Successful in 1m48s
This sets up the last Artifact to target /tmp as a writable overlay mount backed by the host side temp directory. This is useful for an Artifact containing source code to be built for another Artifact for example. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -89,7 +89,9 @@ func (a *execNetArtifact) Cure(c *CureContext) error {
|
||||
// A private instance of /proc and /dev is made available to the container.
|
||||
//
|
||||
// The working and temporary directories are both created and mounted writable
|
||||
// on /work and /tmp respectively.
|
||||
// on /work and /tmp respectively. If one or more paths target [fhs.AbsTmp], the
|
||||
// final entry is set up as a writable overlay mount on /tmp backed by the host
|
||||
// side temporary directory.
|
||||
//
|
||||
// If the first path targets [fhs.AbsRoot], it is made writable via an overlay
|
||||
// mount with writes going to an ephemeral tmpfs bound to the lifetime of the
|
||||
@@ -273,18 +275,46 @@ func (a *execArtifact) cure(c *CureContext, hostNet bool) (err error) {
|
||||
z.OverlayEphemeral(fhs.AbsRoot, paths[0][0])
|
||||
paths = paths[1:]
|
||||
}
|
||||
var overlayTemp *check.Absolute
|
||||
for _, b := range paths {
|
||||
if b[1].Is(fhs.AbsTmp) {
|
||||
if overlayTemp != nil {
|
||||
z.Bind(overlayTemp, fhs.AbsTmp, 0)
|
||||
}
|
||||
overlayTemp = b[0]
|
||||
continue
|
||||
}
|
||||
z.Bind(b[0], b[1], 0)
|
||||
}
|
||||
z.Bind(
|
||||
c.GetWorkDir(),
|
||||
fhs.AbsRoot.Append("work"),
|
||||
std.BindWritable|std.BindEnsure,
|
||||
).Bind(
|
||||
c.GetTempDir(),
|
||||
fhs.AbsTmp,
|
||||
std.BindWritable|std.BindEnsure,
|
||||
).Proc(fhs.AbsProc).Dev(fhs.AbsDev, true)
|
||||
)
|
||||
if overlayTemp == nil {
|
||||
z.Bind(
|
||||
c.GetTempDir(),
|
||||
fhs.AbsTmp,
|
||||
std.BindWritable|std.BindEnsure,
|
||||
)
|
||||
} else {
|
||||
temp := c.GetTempDir()
|
||||
tempUpper := temp.Append("upper")
|
||||
if err = os.MkdirAll(tempUpper.String(), 0700); err != nil {
|
||||
return
|
||||
}
|
||||
tempWork := temp.Append("work")
|
||||
if err = os.MkdirAll(tempWork.String(), 0700); err != nil {
|
||||
return
|
||||
}
|
||||
z.Overlay(
|
||||
fhs.AbsTmp,
|
||||
tempUpper,
|
||||
tempWork,
|
||||
overlayTemp,
|
||||
)
|
||||
}
|
||||
z.Proc(fhs.AbsProc).Dev(fhs.AbsDev, true)
|
||||
|
||||
if err = z.Start(); err != nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user