Compare commits

..

3 commits

Author SHA1 Message Date
b4310c09a8 readme: ejemplo de cache 2023-01-22 00:44:09 -03:00
62b6f98781 configurar usuario 2023-01-22 00:43:36 -03:00
af3e491626 borrar rootfs cada vez 2023-01-22 00:43:17 -03:00
2 changed files with 10 additions and 1 deletions

View file

@ -17,6 +17,8 @@ func main() {
config, err := readConfig()
must(err)
must(os.RemoveAll("rootfs/"))
must(os.MkdirAll("rootfs/etc/apk/keys", 0700))
must(os.WriteFile("rootfs/etc/apk/repositories", []byte(
`https://dl-cdn.alpinelinux.org/alpine/v3.17/main
@ -66,6 +68,8 @@ https://dl-cdn.alpinelinux.org/alpine/v3.17/community`), 0600))
"--ro-bind", ".", "/src",
"--dev-bind", "/dev", "/dev",
"--bind", tmp, "/work",
"--unshare-user", "--uid", "1000", "--gid", "1000",
"--setenv", "HOME", "/home/repro",
"--chdir", "/work",
},
cachedParams...)
@ -77,6 +81,10 @@ https://dl-cdn.alpinelinux.org/alpine/v3.17/community`), 0600))
// cmd.Stdout = os.Stdout
// cmd.Stderr = os.Stderr
must(cmd.Run(), "bwrap apk add")
cmd = exec.Command("bwrap", append(params,
"--uid", "0",
"adduser", "-u", "1000", "-D", "repro")...)
must(cmd.Run(), "bwrap adduser repro")
cmd = exec.Command("bwrap", append(params, strings.Split(config.Command, " ")...)...)
cmd.Stdout = os.Stdout

View file

@ -17,7 +17,8 @@ file repro-run
```
```sh
echo '{"Command": "/src/test"}' | go run .
echo '{"Command": "/src/test", "Cache": ["/home/repro/.cache/go-build"]}
' | go run .
```
genera